httpserver

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: 2

Documentation

Overview

Httpserver: wasmcloud capability contract for http server

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HttpServerContractId

func HttpServerContractId() string

HttpServerContractId returns the capability contract id for this interface

func HttpServerHandler

func HttpServerHandler(actor_ HttpServer) actor.Handler

HttpServerHandler 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 HttpRequest

type HttpRequest struct {
	// HTTP method. One of: GET,POST,PUT,DELETE,HEAD,OPTIONS,CONNECT,PATCH,TRACE
	Method string
	// full request path
	Path string
	// query string. May be an empty string if there were no query parameters.
	QueryString string
	// map of request headers (string key, string value)
	Header HeaderMap
	// Request body as a byte array. May be empty.
	Body []byte
}

HttpRequest contains data sent to actor about the http request

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 {
	// statusCode is a three-digit number, usually in the range 100-599,
	// A value of 200 indicates success.
	StatusCode uint16
	// Map of headers (string keys, list of values)
	Header HeaderMap
	// Body of response as a byte array. May be an empty array.
	Body []byte
}

HttpResponse contains the actor's response to return to the http client

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

type HttpServer

type HttpServer interface {
	HandleRequest(ctx *actor.Context, arg HttpRequest) (*HttpResponse, error)
}

HttpServer is the contract to be implemented by actor

type HttpServerReceiver

type HttpServerReceiver struct{}

HttpServerReceiver receives messages defined in the HttpServer service interface HttpServer is the contract to be implemented by actor

func (*HttpServerReceiver) Dispatch

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

type HttpServerSender

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

HttpServerSender sends messages to a HttpServer service HttpServer is the contract to be implemented by actor

func NewActorHttpServerSender

func NewActorHttpServerSender(actor_id string) *HttpServerSender

NewActorSender constructs a client for actor-to-actor messaging using the recipient actor's public key

func (*HttpServerSender) HandleRequest

func (s *HttpServerSender) HandleRequest(ctx *actor.Context, arg HttpRequest) (*HttpResponse, error)

Jump to

Keyboard shortcuts

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