httpclient

package module
v0.0.0-...-a418af8 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Httpclient: wasmcloud capability contract for http client

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HttpClientContractId

func HttpClientContractId() string

HttpClientContractId returns the capability contract id for this interface

func HttpClientHandler

func HttpClientHandler(actor_ HttpClient) actor.Handler

HttpClientHandler is called by an actor during `main` to generate a dispatch handler The output of this call should be passed into `actor.RegisterHandlers`

Types

type HeaderMap

type HeaderMap map[string]HeaderValues

map data structure for holding http headers

func CDecodeHeaderMap

func CDecodeHeaderMap(d *cbor.Decoder) (HeaderMap, error)

CDecodeHeaderMap deserializes a HeaderMap using cbor

func MDecodeHeaderMap

func MDecodeHeaderMap(d *msgpack.Decoder) (HeaderMap, error)

MDecodeHeaderMap deserializes a HeaderMap using msgpack

func (*HeaderMap) CEncode

func (o *HeaderMap) CEncode(encoder cbor.Writer) error

CEncode serializes a HeaderMap using cbor

func (*HeaderMap) MEncode

func (o *HeaderMap) MEncode(encoder msgpack.Writer) error

MEncode serializes a HeaderMap using msgpack

type HeaderValues

type HeaderValues []string

func CDecodeHeaderValues

func CDecodeHeaderValues(d *cbor.Decoder) (HeaderValues, error)

CDecodeHeaderValues deserializes a HeaderValues using cbor

func MDecodeHeaderValues

func MDecodeHeaderValues(d *msgpack.Decoder) (HeaderValues, error)

MDecodeHeaderValues deserializes a HeaderValues using msgpack

func (*HeaderValues) CEncode

func (o *HeaderValues) CEncode(encoder cbor.Writer) error

CEncode serializes a HeaderValues using cbor

func (*HeaderValues) MEncode

func (o *HeaderValues) MEncode(encoder msgpack.Writer) error

MEncode serializes a HeaderValues using msgpack

type HttpClient

type HttpClient interface {
	// Issue outgoing http request
	Request(ctx *actor.Context, arg HttpRequest) (*HttpResponse, error)
}

HttpClient - issue outgoing http requests via an external provider To use this capability, the actor must be linked with "wasmcloud:httpclient"

type HttpClientReceiver

type HttpClientReceiver struct{}

HttpClientReceiver receives messages defined in the HttpClient service interface HttpClient - issue outgoing http requests via an external provider To use this capability, the actor must be linked with "wasmcloud:httpclient"

func (*HttpClientReceiver) Dispatch

func (r *HttpClientReceiver) Dispatch(ctx *actor.Context, svc interface{}, message *actor.Message) (*actor.Message, error)

type HttpClientSender

type HttpClientSender struct {
	// contains filtered or unexported fields
}

HttpClientSender sends messages to a HttpClient service HttpClient - issue outgoing http requests via an external provider To use this capability, the actor must be linked with "wasmcloud:httpclient"

func NewProviderHttpClient

func NewProviderHttpClient() *HttpClientSender

NewProvider constructs a client for sending to a HttpClient provider implementing the 'wasmcloud:httpclient' capability contract, with the "default" link

func NewProviderHttpClientLink(linkName string) *HttpClientSender

NewProviderHttpClientLink constructs a client for sending to a HttpClient provider implementing the 'wasmcloud:httpclient' capability contract, with the specified link name

func (*HttpClientSender) Request

func (s *HttpClientSender) Request(ctx *actor.Context, arg HttpRequest) (*HttpResponse, error)

Issue outgoing http request

type HttpRequest

type HttpRequest struct {
	// http method, defaults to "GET"
	Method string
	Url    string
	// optional headers. defaults to empty
	Headers HeaderMap
	// request body, defaults to empty
	Body []byte
}

http request to be sent through the provider

func CDecodeHttpRequest

func CDecodeHttpRequest(d *cbor.Decoder) (HttpRequest, error)

CDecodeHttpRequest deserializes a HttpRequest using cbor

func MDecodeHttpRequest

func MDecodeHttpRequest(d *msgpack.Decoder) (HttpRequest, error)

MDecodeHttpRequest deserializes a HttpRequest using msgpack

func (*HttpRequest) CEncode

func (o *HttpRequest) CEncode(encoder cbor.Writer) error

CEncode serializes a HttpRequest using cbor

func (*HttpRequest) MEncode

func (o *HttpRequest) MEncode(encoder msgpack.Writer) error

MEncode serializes a HttpRequest using msgpack

type HttpResponse

type HttpResponse struct {
	// response status code
	StatusCode uint16
	// Case is not guaranteed to be normalized, so
	// actors checking response headers need to do their own
	// case conversion.
	// Example (rust):
	// // check for 'Content-Type' header
	// let content_type:Option<&Vec<String>> = header.iter()
	// .map(|(k,_)| k.to_ascii_lowercase())
	// .find(|(k,_)| k == "content-type")
	// .map(|(_,v)| v);
	Header HeaderMap
	// response body
	Body []byte
}

response from the http request

func CDecodeHttpResponse

func CDecodeHttpResponse(d *cbor.Decoder) (HttpResponse, error)

CDecodeHttpResponse deserializes a HttpResponse using cbor

func MDecodeHttpResponse

func MDecodeHttpResponse(d *msgpack.Decoder) (HttpResponse, error)

MDecodeHttpResponse deserializes a HttpResponse using msgpack

func (*HttpResponse) CEncode

func (o *HttpResponse) CEncode(encoder cbor.Writer) error

CEncode serializes a HttpResponse using cbor

func (*HttpResponse) MEncode

func (o *HttpResponse) MEncode(encoder msgpack.Writer) error

MEncode serializes a HttpResponse using msgpack

Jump to

Keyboard shortcuts

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