handler

package
v0.0.0-...-767c95f Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2023 License: AGPL-3.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultRuntime

func DefaultRuntime(ctx context.Context) (wazero.Runtime, error)

DefaultRuntime implements options.newRuntime.

Types

type Middleware

type Middleware interface {
	// HandleRequest handles a request by calling handler.FuncHandleRequest on
	// the guest.
	//
	// Note: If the handler.CtxNext is returned with `next=1`, you must call
	// HandleResponse.
	HandleRequest(ctx context.Context) (outCtx context.Context, ctxNext handler.CtxNext, err error)

	// HandleResponse handles a response by calling handler.FuncHandleResponse
	// on the guest. This is only called when HandleRequest returns
	// handler.CtxNext with `next=1`.
	//
	// The ctx and ctxNext parameters are those returned from HandleRequest.
	// Specifically, the handler.CtxNext "ctx" field is passed as `reqCtx`.
	// The err parameter is nil unless the host erred processing the next
	// handler.
	HandleResponse(ctx context.Context, reqCtx uint32, err error) error

	// Features are the features enabled while initializing the guest. This
	// value won't change per-request.
	Features() handler.Features

	api.Closer
}

Middleware implements the http-wasm handler ABI. It is scoped to a single guest binary.

func NewMiddleware

func NewMiddleware(ctx context.Context, guest []byte, host handler.Host, opts ...Option) (Middleware, error)

type NewRuntime

type NewRuntime func(context.Context) (wazero.Runtime, error)

NewRuntime returns a new wazero runtime which is called when creating a new middleware instance, which also closes it.

type Option

type Option func(*options)

Option is configuration for NewMiddleware

func GuestConfig

func GuestConfig(guestConfig []byte) Option

GuestConfig is the configuration used to instantiate the guest.

func Logger

func Logger(logger api.Logger) Option

Logger sets the logger used by the guest when it calls "log". Defaults to api.NoopLogger.

func ModuleConfig

func ModuleConfig(moduleConfig wazero.ModuleConfig) Option

ModuleConfig is the configuration used to instantiate the guest.

func Runtime

func Runtime(newRuntime NewRuntime) Option

Runtime provides the wazero.Runtime and defaults to wazero.NewRuntime.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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