retrieval

package
v0.0.0-...-53ebe2f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2026 License: Apache-2.0, MIT Imports: 11 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultHTTPHeaderInboundCodec  = &HTTPHeaderInboundCodec{}
	DefaultHTTPHeaderOutboundCodec = &HTTPHeaderOutboundCodec{}
	HTTPHeaderName                 = "X-UCAN-Container"
)

Functions

This section is empty.

Types

type ClientOption

type ClientOption func(*httpHeaderClientConfig) error

func WithEventListener

func WithEventListener(listener client.EventListener) ClientOption

WithEventListener adds an event listener to the HTTP client for monitoring requests and responses.

func WithHTTPClient

func WithHTTPClient(client *http.Client) ClientOption

func WithHTTPHeaders

func WithHTTPHeaders(headers http.Header) ClientOption

WithHTTPHeaders adds custom HTTP headers to EVERY request. Note that the "X-UCAN-Container" header is reserved for encoding the UCAN invocation and should not be included in the provided headers.

type HTTPHeaderClient

type HTTPHeaderClient struct {
	*client.Client[*http.Request, *http.Response]
}

func NewClient

func NewClient(serviceURL *url.URL, options ...ClientOption) (*HTTPHeaderClient, error)

func (*HTTPHeaderClient) Execute

func (c *HTTPHeaderClient) Execute(execRequest execution.Request) (execution.Response, error)

Note: execution response metadata is a HTTPHeaderResponseContainer and it is the caller's responsibility to close the response body.

type HTTPHeaderInboundCodec

type HTTPHeaderInboundCodec struct{}

func (*HTTPHeaderInboundCodec) Decode

func (*HTTPHeaderInboundCodec) Encode

type HTTPHeaderOutboundCodec

type HTTPHeaderOutboundCodec struct{}

func (*HTTPHeaderOutboundCodec) Decode

func (*HTTPHeaderOutboundCodec) Encode

type HTTPHeaderRequestContainer

type HTTPHeaderRequestContainer struct {
	ucan.Container
	Method string
	URL    *url.URL
	Header http.Header
	Body   io.ReadCloser
}

type HTTPHeaderResponseContainer

type HTTPHeaderResponseContainer struct {
	ucan.Container
	StatusCode int
	Header     http.Header
	Body       io.ReadCloser
}

type HTTPResponseContainer

type HTTPResponseContainer struct {
	ucan.Container
	Response *http.Response
}

type Server

type Server struct {
	*server.HTTPServer
	// contains filtered or unexported fields
}

Server is a UCAN server that accepts a single executable invocation carried in the "X-UCAN-Container" HTTP header, leaving the request and response bodies free to transport raw bytes for the requested blob.

The original HTTP request is exposed to handlers as a *HTTPHeaderRequestContainer on the execution request metadata, and a handler may set a *HTTPHeaderResponseContainer as its response metadata to control the HTTP response status code, headers and body.

Since the request and response bodies can only service a single retrieval, the request container MUST contain exactly one invocation addressed to this server (additional invocations not addressed to the server are permitted and ignored).

func NewServer

func NewServer(id ucan.Issuer, options ...server.HTTPOption) *Server

NewServer creates a new UCAN retrieval server.

func (*Server) RoundTrip

func (s *Server) RoundTrip(r *http.Request) (*http.Response, error)

RoundTrip unpacks and executes an incoming request, returning the response.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL