web

package
v1.19.3 Latest Latest
Warning

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

Go to latest
Published: May 3, 2023 License: MIT Imports: 9 Imported by: 24

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bind

func Bind[T any](obj T) http.HandlerFunc

Bind binding an obj to a handler

func GetForm

func GetForm(data middleware.DataStore) interface{}

GetForm returns the validate form information

func Middle

func Middle(f func(ctx *context.Context)) func(next http.Handler) http.Handler

Middle wrap a context function as a chi middleware

func MiddleAPI

func MiddleAPI(f func(ctx *context.APIContext)) func(next http.Handler) http.Handler

MiddleAPI wrap a context function as a chi middleware

func MiddleCancel added in v1.14.2

func MiddleCancel(f func(ctx *context.Context) goctx.CancelFunc) func(netx http.Handler) http.Handler

MiddleCancel wrap a context function as a chi middleware

func SetForm

func SetForm(data middleware.DataStore, obj interface{})

SetForm set the form object

func Wrap

func Wrap(handlers ...interface{}) http.HandlerFunc

Wrap converts all kinds of routes to standard library one

func WrapWithPrefix added in v1.17.0

func WrapWithPrefix(pathPrefix string, handler http.HandlerFunc, friendlyName ...string) func(next http.Handler) http.Handler

WrapWithPrefix wraps a provided handler function at a prefix

Types

type Combo

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

Combo represents a tiny group routes with same pattern

func (*Combo) Delete

func (c *Combo) Delete(h ...interface{}) *Combo

Delete deletegate Delete method

func (*Combo) Get

func (c *Combo) Get(h ...interface{}) *Combo

Get deletegate Get method

func (*Combo) Patch

func (c *Combo) Patch(h ...interface{}) *Combo

Patch deletegate Patch method

func (*Combo) Post

func (c *Combo) Post(h ...interface{}) *Combo

Post deletegate Post method

func (*Combo) Put

func (c *Combo) Put(h ...interface{}) *Combo

Put deletegate Put method

type Route

type Route struct {
	R chi.Router
	// contains filtered or unexported fields
}

Route defines a route based on chi's router

func NewRoute

func NewRoute() *Route

NewRoute creates a new route

func (*Route) Any

func (r *Route) Any(pattern string, h ...interface{})

Any delegate requests for all methods

func (*Route) Combo

func (r *Route) Combo(pattern string, h ...interface{}) *Combo

Combo deletegate requests to Combo

func (*Route) Delete

func (r *Route) Delete(pattern string, h ...interface{})

Delete delegate delete method

func (*Route) Get

func (r *Route) Get(pattern string, h ...interface{})

Get delegate get method

func (*Route) GetOptions added in v1.15.0

func (r *Route) GetOptions(pattern string, h ...interface{})

GetOptions delegate get and options method

func (*Route) Group

func (r *Route) Group(pattern string, fn func(), middlewares ...interface{})

Group mounts a sub-Router along a `pattern` string.

func (*Route) Head

func (r *Route) Head(pattern string, h ...interface{})

Head delegate head method

func (*Route) MethodNotAllowed

func (r *Route) MethodNotAllowed(h http.HandlerFunc)

MethodNotAllowed defines a handler to respond whenever a method is not allowed.

func (*Route) Mount

func (r *Route) Mount(pattern string, subR *Route)

Mount attaches another Route along ./pattern/*

func (*Route) NotFound

func (r *Route) NotFound(h http.HandlerFunc)

NotFound defines a handler to respond whenever a route could not be found.

func (*Route) Options added in v1.15.0

func (r *Route) Options(pattern string, h ...interface{})

Options delegate options method

func (*Route) Patch

func (r *Route) Patch(pattern string, h ...interface{})

Patch delegate patch method

func (*Route) Post

func (r *Route) Post(pattern string, h ...interface{})

Post delegate post method

func (*Route) PostOptions added in v1.15.0

func (r *Route) PostOptions(pattern string, h ...interface{})

PostOptions delegate post and options method

func (*Route) Put

func (r *Route) Put(pattern string, h ...interface{})

Put delegate put method

func (*Route) Route

func (r *Route) Route(pattern, methods string, h ...interface{})

Route delegate special methods

func (*Route) ServeHTTP

func (r *Route) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP implements http.Handler

func (*Route) Use

func (r *Route) Use(middlewares ...interface{})

Use supports two middlewares

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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