OCI.Plug.Parser (oci v0.0.6)

View Source

Parses the request body for OCI requests.

This module is responsible for parsing the request body for OCI requests. It implements the Plug.Parsers behaviour to handle different content types specific to OCI (Open Container Initiative) operations.

Content Types Handled

  • application/octet-stream: For binary blob uploads
  • application/vnd.oci.image.manifest.v1+json: For OCI image manifests

Summary

Functions

Parses the request body based on the content type.

Types

opts()

@type opts() :: keyword()

Functions

parse(conn, arg2, arg3, headers, opts)

Parses the request body based on the content type.

Content Types Handled

application/octet-stream

Handles binary blob uploads by reading the full body and storing it in the connection assigns under the :oci_blob_chunk key.

application/vnd.oci.image.manifest.v1+json

Handles OCI image manifest uploads by:

  1. Reading the full body
  2. Computing its SHA256 digest
  3. Storing the digest in the connection assigns
  4. Decoding the JSON manifest

Other Content Types

Passes through to the next parser in the chain.

Parameters

  • conn: The Plug.Conn struct
  • type: The content type
  • subtype: The content subtype
  • headers: The request headers
  • opts: Parser options containing a :json_decoder key for manifest parsing

Returns

  • For octet-stream: {:ok, %{}, conn} on successful parsing
  • For manifest: {:ok, manifest, conn} on successful parsing
  • For other types: {:next, conn} to pass to the next parser
  • {:error, reason} on failure
  • Raises Plug.Parsers.ParseError on JSON decode failure for manifests