handler

package
v0.2.10 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: MIT Imports: 1 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByWeight added in v0.2.0

type ByWeight []Middleware

ByWeight sorts a list of Middleware by Weight

func (ByWeight) Len added in v0.2.0

func (b ByWeight) Len() int

Len returns the length of the list

func (ByWeight) Less added in v0.2.0

func (b ByWeight) Less(i, j int) bool

func (ByWeight) Swap added in v0.2.0

func (b ByWeight) Swap(i, j int)

type Factory

type Factory func() Handler

Factory is a function that return a new Handler It is useful if you want to create a Handler that will carry request-scoped data.

type Func

type Func func(http.ResponseWriter, *http.Request) (interface{}, error)

Func type is an adapter to allow the use of ordinary functions as HTTP handlers. If f is a function with the appropriate signature, handler.Func(f) is a Handler that calls f

func (Func) Serve

func (f Func) Serve(w http.ResponseWriter, r *http.Request) (interface{}, error)

Serve implements the handler.Handler interface

type Handler

type Handler interface {
	Serve(http.ResponseWriter, *http.Request) (interface{}, error)
}

Handler is able to respond to a http request and return the response it wants to write and an error. You need to use a middleware to write your response if you just return your response and not write it. (see github.com/mwm-io/gapi/middleware.ResponseWriter)

type Middleware

type Middleware interface {
	Wrap(Handler) Handler
}

Middleware is able to wrap a given Handler to build a new one.

type MiddlewareAware

type MiddlewareAware interface {
	Middlewares() []Middleware
}

MiddlewareAware is a struct containing its own middlewares.

type SortableMiddleware added in v0.2.0

type SortableMiddleware interface {
	Middleware
	Weight() int
}

SortableMiddleware embeds Middleware type with a Weight method in order to get sorted.

type WithMiddlewares

type WithMiddlewares struct {
	MiddlewareList []Middleware
}

WithMiddlewares implements the request.MiddlewareAware interface and is meant to be embedded into the final handler

func (WithMiddlewares) Middlewares

func (p WithMiddlewares) Middlewares() []Middleware

Middlewares implements the request.MiddlewareAware interface

Jump to

Keyboard shortcuts

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