web

package
v1.21.0-dev Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2023 License: MIT Imports: 11 Imported by: 24

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bind

func Bind[T any](_ T) any

Bind binding an obj to a handler

func GetForm

func GetForm(data middleware.ContextDataStore) interface{}

GetForm returns the validate form information

func RegisterHandleTypeProvider added in v1.20.0

func RegisterHandleTypeProvider[T any](fn func(req *http.Request) ResponseStatusProvider)

func SetForm

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

SetForm set the form object

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 delegates Delete method

func (*Combo) Get

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

Get delegates Get method

func (*Combo) Patch

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

Patch delegates Patch method

func (*Combo) Post

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

Post delegates Post method

func (*Combo) Put

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

Put delegates Put method

type ResponseStatusProvider added in v1.20.0

type ResponseStatusProvider interface {
	Written() bool
}

ResponseStatusProvider is an interface to check whether the response has been written by the handler

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 delegates 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) Methods added in v1.20.0

func (r *Route) Methods(method, pattern string, h []any)

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) 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) RouteMethods added in v1.20.0

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

RouteMethods delegate special methods, it is an alias of "Methods", while the "pattern" is the first parameter

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