OCI.Plug.Parser (oci v0.0.6)
View SourceParses 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 uploadsapplication/vnd.oci.image.manifest.v1+json
: For OCI image manifests
Summary
Functions
Parses the request body based on the content type.
Types
@type opts() :: keyword()
Functions
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:
- Reading the full body
- Computing its SHA256 digest
- Storing the digest in the connection assigns
- 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