handler

package
v0.3.10 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewContentHandler added in v0.3.3

func NewContentHandler(cfg tree.Map, _ logger.Logger) (fasthttp.RequestHandler, error)

NewContentHandler creates a new fasthttp.RequestHandler via Content.Handle.

func NewExpvarHandler added in v0.3.3

func NewExpvarHandler(cfg tree.Map, l logger.Logger) (fasthttp.RequestHandler, error)

NewExpvarHandler returns a ExpvarHandler that dumps json representation of expvars to http response. Refer to https://github.com/valyala/fasthttp/tree/master/expvarhandler

func NewFS added in v0.1.0

func NewFS(cfg tree.Map) (*fasthttp.FS, error)

NewFS creates a fasthttp.FS. The specified cfg must have 'root' entry.

func NewFSHandler

func NewFSHandler(cfg tree.Map, l logger.Logger) (fasthttp.RequestHandler, error)

NewFSHandler creates a new fasthttp.RequestHandler via fasthttp.FS.

func NewHandler

func NewHandler(cfg tree.Map, l logger.Logger) (fasthttp.RequestHandler, error)

NewHandler creates a new fasthttp.RequestHandler.

func NewProxyHandler

func NewProxyHandler(cfg tree.Map, l logger.Logger) (fasthttp.RequestHandler, error)

NewProxyHandler creates a new a proxy handler that proxies to backend url. The specified cfg must have 'url' entry.

func RegisterNewHandlerFunc

func RegisterNewHandlerFunc(typeName string, fn NewHandlerFunc)

RegisterNewHandlerFunc registers a NewHandlerFunc with the specified type name.

func SendDefaultError added in v0.3.7

func SendDefaultError(ctx *fasthttp.RequestCtx)

SendDefaultError sends default error page using ctx.Response.StatusCode(). It works as fasthttp.RequestHandler. If the provided ctx has response body, it does nothing.

Types

type Content added in v0.3.3

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

Content represents a handler that provides a simple content.

func NewContent added in v0.3.3

func NewContent(cfg tree.Map) (*Content, error)

NewContent creates a new Content that provides a simple content. The cfg can be specified 'body' string and 'headers' map.

func (*Content) Handle added in v0.3.3

func (h *Content) Handle(ctx *fasthttp.RequestCtx)

Handle sets headers and body to the provided ctx.

type ErrorPages

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

ErrorPages represents a handler that provides custom error pages.

func NewErrorPages

func NewErrorPages(root string, statusToPath map[string]string) *ErrorPages

NewErrorPages creates a new ErrorPages. The statusToPath maps from a http status text to a path of error page. A http status text can be contain 'x' as wildcard. (eg. '404', '40x')

func (*ErrorPages) Handle

func (p *ErrorPages) Handle(ctx *fasthttp.RequestCtx)

type NewHandlerFunc

type NewHandlerFunc func(cfg tree.Map, l logger.Logger) (fasthttp.RequestHandler, error)

NewHandlerFunc is a function that creates a new fasthttp.RequestHandler.

type ServerHandler added in v0.3.3

type ServerHandler interface {
	// Config returns the config.Config.Server.
	Config() tree.Map
	// Logger returns a logger.
	Logger() logger.Logger
	// Handle handles the provided request.
	Handle(ctx *fasthttp.RequestCtx)
	// HandleError implements fasthttp.Server.ErrorHandler.
	HandleError(ctx *fasthttp.RequestCtx, err error)
	// Close closes the server.
	Close() error
}

ServerHandler is an interface that defines the methods to handle a server.

func NewServerHandler added in v0.3.3

func NewServerHandler(cfgs []config.Config) (ServerHandler, error)

NewServerHandler creates a new ServerHandler by the provided cfgs.

Jump to

Keyboard shortcuts

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