handler

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 26, 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 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 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