web

package
v1.14.0-rc8 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bind

func Bind(obj interface{}) 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(netx http.Handler) http.Handler

Middle wrap a context function as a chi middleware

func MiddleAPI

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

MiddleAPI 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

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) 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) 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) Put

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

Put delegate put method

func (*Route) Route

func (r *Route) Route(pattern string, 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