Documentation
¶
Index ¶
- func Client(options ...Option) (*client.Client, error)
- func ComposeOptions[C any](opts ...func(C)) func(C)
- func NewPutClient() *http.Client
- func NewRetrievalClient(t *testing.T, service principal.Signer, testData []byte, ...) *http.Client
- func NewTestServerConnection(options ...server.Option) uclient.Connection
- func Ptr[T any](v T) *T
- func SpaceBlobAddHandler(rcptIssued func(rcpt receipt.AnyReceipt), includePDP bool, ...) (...)
- func Urls(strs ...string) []url.URL
- type BlobMap
- type BlobReceiver
- type ClientWithCustomPut
- type Option
- type RetrievalClientOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Client ¶
Client creates an entire client.Client with a connection to an in-process server, each configured with the given options.
func ComposeOptions ¶
func ComposeOptions[C any](opts ...func(C)) func(C)
ComposeOptions combines multiple options into one. It's written generically so that it might someday move somewhere more generic, but so far it's only being used here anyhow.
func NewPutClient ¶
NewPutClient creates a new mock http.Client that accepts and tracks any PUT request, without making an actual network request.
func NewRetrievalClient ¶
func NewRetrievalClient(t *testing.T, service principal.Signer, testData []byte, opts ...RetrievalClientOption) *http.Client
NewRetrievalClient creates an in-process retrieval server and returns an HTTP client that can connect to it directly (without network I/O). By default, the server validates that: - URL hash (from path /blob/<hash>) - Capability hash (from invocation) - Actual data hash all match before serving the content.
Use WithoutHashValidation() to disable hash validation for testing client-side validation.
func NewTestServerConnection ¶
func NewTestServerConnection(options ...server.Option) uclient.Connection
NewTestServerConnection creates a new Ucanto server and a connection to it. It accepts `server.Option`s to configure the server. This is mainly (if not exclusively) to provide service methods.
The server generates its own service principal. It has a `did:web:` DID for realism and readability in errors and failures, but calling code should use `connection.ID()` to get it rather than assume knowledge of the DID it picks.
func SpaceBlobAddHandler ¶
func SpaceBlobAddHandler( rcptIssued func(rcpt receipt.AnyReceipt), includePDP bool, includePutReceipt bool, ) (server.HandlerFunc[spaceblobcap.AddCaveats, spaceblobcap.AddOk, failure.IPLDBuilderFailure], error)
SpaceBlobAddHandler returns a mock server.HandlerFunc to handles spaceblobcap.Add invocations in a test. rcptIssued is called with each receipt that is issued along the way. If includePDP is true, the accept receipt will include a (random) PDP accept link; otherwise, the PDP accept link will be nil. If includePutReceipt is true, a successful http/put receipt is embedded in the response (simulating a blob that was already uploaded).
Types ¶
type BlobMap ¶
func ReceivedBlobs ¶
type BlobReceiver ¶
type BlobReceiver interface {
ReceivedBlobs() BlobMap
}
type ClientWithCustomPut ¶
ClientWithCustomPut is a client.Client that uses a custom client for PUT requests from [SpaceBlobAdd].
func (*ClientWithCustomPut) SpaceBlobAdd ¶
type Option ¶
type Option func(*clientServerConfig)
func WithClientOptions ¶
WithClientOptions appends options to the client configuration.
func WithServerOptions ¶
WithServerOptions appends options to the server configuration.
func WithSpaceBlobAdd ¶
func WithSpaceBlobAdd() Option
WithSpaceBlobAdd creates an Option that adds `space/blob/add` support to the server. NB: This takes over the receipts client entirely. Currently, different options can't cooperate to share a receipts client. That's solvable, but hasn't been necessary yet.
func WithSpaceBlobAddPDP ¶
func WithSpaceBlobAddPDP() Option
WithSpaceBlobAddPDP is like WithSpaceBlobAdd but includes a PDP accept link in the accept receipt.
func WithSpaceBlobAddPutReceipt ¶ added in v0.5.3
func WithSpaceBlobAddPutReceipt() Option
WithSpaceBlobAddPutReceipt is like WithSpaceBlobAdd but includes a successful http/put receipt in the space/blob/add response, simulating a blob that was already uploaded by a previous attempt.
type RetrievalClientOption ¶
type RetrievalClientOption func(*retrievalClientConfig)
RetrievalClientOption configures a retrieval client.
func WithoutHashValidation ¶
func WithoutHashValidation() RetrievalClientOption
WithoutHashValidation disables server-side hash validation. This is useful for testing client-side validation.