handler

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2022 License: Apache-2.0 Imports: 12 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultNamespace

func DefaultNamespace(ctx context.Context, r wazero.Runtime) (wazero.Namespace, error)

DefaultNamespace implements options.newNamespace.

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.
	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 NewNamespace

type NewNamespace func(context.Context, wazero.Runtime) (wazero.Namespace, error)

NewNamespace returns a new wazero namespace which is called when creating a new handler instance, which also closes it.

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 Namespace

func Namespace(newNamespace NewNamespace) Option

Namespace provides the wazero.Namespace and defaults to one that with wasi_snapshot_preview1.ModuleName instantiated.

func Runtime

func Runtime(newRuntime NewRuntime) Option

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

Directories

Path Synopsis
fasthttp module
mosn module

Jump to

Keyboard shortcuts

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