httpsrv

package
v0.30.113 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 31 Imported by: 3

Documentation

Index

Constants

View Source
const ComposerKey contextKey = 0

ComposerKey is used to access the miruken.Handler from the context.

Variables

This section is empty.

Functions

func Api added in v0.22.0

func Api(
	ctx *context.Context,
	middleware ...any,
) http.Handler

Api builds a http.Handler for processing polymorphic api calls through a Middleware pipeline.

func Feature

func Feature(config ...func(*Installer)) setup.Feature

Feature configures http server support

func ListenAndServe added in v0.30.92

func ListenAndServe(
	handler http.Handler,
	config *Config,
) error

ListenAndServe creates and starts a http.Server with the provided configuration.

func New added in v0.30.87

func New(
	handler http.Handler,
	config *Config,
) *http.Server

New creates a new http.Server with the provided configuration.

func Use added in v0.30.45

func Use(
	ctx *context.Context,
	handler any,
	middleware ...any,
) http.Handler

Use builds an enhanced http.Handler for processing requests through a Middleware pipeline and terminating at a provided handler.

Types

type Config added in v0.30.87

type Config struct {
	Addr              string
	ReadTimeout       time.Duration
	ReadHeaderTimeout time.Duration
	WriteTimeout      time.Duration
	IdleTimeout       time.Duration
	MaxHeaderBytes    int
}

Config provides http.Server configuration.

type Handler added in v0.26.0

type Handler interface {
	ServeHTTP(
		w http.ResponseWriter,
		r *http.Request,
		h miruken.Handler,
	)
}

Handler augments http.Handler to provide miruken.Handler composer.

func H added in v0.30.46

func H[H any](opts ...any) Handler

H builds a typed Handler wrapper for dynamic http processing.

type HandlerFunc added in v0.30.41

type HandlerFunc func(
	w http.ResponseWriter,
	r *http.Request,
	h miruken.Handler,
)

HandlerFunc promotes a function to Handler.

func (HandlerFunc) ServeHTTP added in v0.30.41

func (f HandlerFunc) ServeHTTP(
	w http.ResponseWriter,
	r *http.Request,
	h miruken.Handler,
)

type Installer

type Installer struct{}

Installer configures http server support

func (*Installer) DependsOn

func (i *Installer) DependsOn() []setup.Feature

func (*Installer) Install

func (i *Installer) Install(b *setup.Builder) error

type Middleware added in v0.30.5

type Middleware interface {
	ServeHTTP(
		http.ResponseWriter,
		*http.Request,
		miruken.Handler,
		func(miruken.Handler),
	)
}

Middleware augments Handler to participate in a pipeline to support pre and post processing of requests.

func M added in v0.30.46

func M[M any](opts ...any) Middleware

M builds a typed Middleware wrapper for dynamic http processing.

func Pipe added in v0.30.41

func Pipe(middleware ...any) Middleware

Pipe builds a Middleware chain for pre and post processing of http requests.

type MiddlewareFunc added in v0.30.5

type MiddlewareFunc func(
	w http.ResponseWriter,
	r *http.Request,
	h miruken.Handler,
	n func(miruken.Handler),
)

MiddlewareFunc promotes a function to Middleware.

func (MiddlewareFunc) ServeHTTP added in v0.30.5

func (f MiddlewareFunc) ServeHTTP(
	w http.ResponseWriter,
	r *http.Request,
	h miruken.Handler,
	n func(miruken.Handler),
)

type PolyHandler added in v0.30.46

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

PolyHandler is a Handler for processing polymorphic http requests.

func (*PolyHandler) Constructor added in v0.30.46

func (a *PolyHandler) Constructor(
	_ *struct{ args.Optional }, logger logr.Logger,
)

func (*PolyHandler) ServeHTTP added in v0.30.46

func (a *PolyHandler) ServeHTTP(
	w http.ResponseWriter,
	r *http.Request,
	h miruken.Handler,
)

type StatusCodeMapper

type StatusCodeMapper struct{}

StatusCodeMapper maps errors into a corresponding http status code.

func (*StatusCodeMapper) AccessDenied added in v0.30.7

func (s *StatusCodeMapper) AccessDenied(
	_ *struct {
		maps.It
		maps.Format `to:"http:status-code"`
	}, _ *authorizes.AccessDeniedError,
	_ *struct{ args.Optional }, subject security.Subject,
) int

func (*StatusCodeMapper) JsonSyntax added in v0.21.0

func (s *StatusCodeMapper) JsonSyntax(
	_ *struct {
		maps.It
		maps.Format `to:"http:status-code"`
	}, _ *json.SyntaxError,
) int

func (*StatusCodeMapper) NotHandled added in v0.21.0

func (s *StatusCodeMapper) NotHandled(
	_ *struct {
		maps.It
		maps.Format `to:"http:status-code"`
	}, _ *miruken.NotHandledError,
) int

func (*StatusCodeMapper) UnknownTypeId added in v0.21.0

func (s *StatusCodeMapper) UnknownTypeId(
	_ *struct {
		maps.It
		maps.Format `to:"http:status-code"`
	}, _ *api.UnknownTypeIdError,
) int

func (*StatusCodeMapper) Validation added in v0.21.0

func (s *StatusCodeMapper) Validation(
	_ *struct {
		maps.It
		maps.Format `to:"http:status-code"`
	}, _ *validates.Outcome,
) int

Directories

Path Synopsis
ui

Jump to

Keyboard shortcuts

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