Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
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 ¶
func NewClient ¶
func NewClient(serviceURL *url.URL, options ...ClientOption) (*HTTPHeaderClient, error)
func (*HTTPHeaderClient) Execute ¶
Note: execution response metadata is a HTTPHeaderResponseContainer and it is the caller's responsibility to close the response body.
type HTTPHeaderInboundCodec ¶
type HTTPHeaderInboundCodec struct{}
type HTTPHeaderOutboundCodec ¶
type HTTPHeaderOutboundCodec struct{}
type HTTPResponseContainer ¶
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 ¶
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.