routing

package
v11.1.4-modfix Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ServerError = func(err error) response.Response {
		return response.Error(http.StatusInternalServerError, "Server error", err)
	}
)

Functions

func Wrap

func Wrap(handler func(c *contextmodel.ReqContext) response.Response) web.Handler

Types

type RegisterNamedMiddleware

type RegisterNamedMiddleware func(name string) web.Handler

type RouteRegister

type RouteRegister interface {
	// Get adds a list of handlers to a given route with a GET HTTP verb
	Get(string, ...web.Handler)

	// Post adds a list of handlers to a given route with a POST HTTP verb
	Post(string, ...web.Handler)

	// Delete adds a list of handlers to a given route with a DELETE HTTP verb
	Delete(string, ...web.Handler)

	// Put adds a list of handlers to a given route with a PUT HTTP verb
	Put(string, ...web.Handler)

	// Patch adds a list of handlers to a given route with a PATCH HTTP verb
	Patch(string, ...web.Handler)

	// Any adds a list of handlers to a given route with any HTTP verb
	Any(string, ...web.Handler)

	// Group allows you to pass a function that can add multiple routes
	// with a shared prefix route.
	Group(string, func(RouteRegister), ...web.Handler)

	// Insert adds more routes to an existing Group.
	Insert(string, func(RouteRegister), ...web.Handler)

	// Register iterates over all routes added to the RouteRegister
	// and add them to the `Router` pass as an parameter.
	Register(Router, ...RegisterNamedMiddleware)

	// Reset resets the route register.
	Reset()
}

RouteRegister allows you to add routes and web.Handlers that the web server should serve.

type RouteRegisterImpl

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

func NewRouteRegister

func NewRouteRegister(namedMiddlewares ...RegisterNamedMiddleware) *RouteRegisterImpl

NewRouteRegister creates a new RouteRegister with all middlewares sent as params

func ProvideRegister

func ProvideRegister() *RouteRegisterImpl

func (*RouteRegisterImpl) Any

func (rr *RouteRegisterImpl) Any(pattern string, handlers ...web.Handler)

func (*RouteRegisterImpl) Delete

func (rr *RouteRegisterImpl) Delete(pattern string, handlers ...web.Handler)

func (*RouteRegisterImpl) Get

func (rr *RouteRegisterImpl) Get(pattern string, handlers ...web.Handler)

func (*RouteRegisterImpl) Group

func (rr *RouteRegisterImpl) Group(pattern string, fn func(rr RouteRegister), handlers ...web.Handler)

func (*RouteRegisterImpl) Insert

func (rr *RouteRegisterImpl) Insert(pattern string, fn func(RouteRegister), handlers ...web.Handler)

func (*RouteRegisterImpl) Patch

func (rr *RouteRegisterImpl) Patch(pattern string, handlers ...web.Handler)

func (*RouteRegisterImpl) Post

func (rr *RouteRegisterImpl) Post(pattern string, handlers ...web.Handler)

func (*RouteRegisterImpl) Put

func (rr *RouteRegisterImpl) Put(pattern string, handlers ...web.Handler)

func (*RouteRegisterImpl) Register

func (rr *RouteRegisterImpl) Register(router Router, namedMiddlewares ...RegisterNamedMiddleware)

func (*RouteRegisterImpl) Reset

func (rr *RouteRegisterImpl) Reset()

type Router

type Router interface {
	Handle(method, pattern string, handlers []web.Handler)
	Get(pattern string, handlers ...web.Handler)
}

Jump to

Keyboard shortcuts

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