router

package
v0.0.0-...-174ac3b Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DELETE  = "DELETE"
	GET     = "GET"
	HEAD    = "HEAD"
	OPTIONS = "OPTIONS"
	PATCH   = "PATCH"
	POST    = "POST"
	PUT     = "PUT"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Router

type Router struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func New

func New() *Router

func (*Router) AddRoute

func (r *Router) AddRoute(method string, pattern string, handler http.HandlerFunc)

Adds a new Route to the Handler

func (*Router) Del

func (r *Router) Del(pattern string, handler http.HandlerFunc)

Del adds a new Route for DELETE requests.

func (*Router) Filter

func (r *Router) Filter(filter http.HandlerFunc)

Filter adds the middleware filter.

func (*Router) FilterParam

func (r *Router) FilterParam(param string, filter http.HandlerFunc)

FilterParam adds the middleware filter iff the URL parameter exists.

func (*Router) FilterPath

func (r *Router) FilterPath(path string, filter http.HandlerFunc)

FilterPath adds the middleware filter iff the path matches the request.

func (*Router) Get

func (r *Router) Get(pattern string, handler http.HandlerFunc)

Get adds a new Route for GET requests.

func (*Router) Patch

func (r *Router) Patch(pattern string, handler http.HandlerFunc)

Patch adds a new Route for PATCH requests.

func (*Router) Post

func (r *Router) Post(pattern string, handler http.HandlerFunc)

Post adds a new Route for POST requests.

func (*Router) Put

func (r *Router) Put(pattern string, handler http.HandlerFunc)

Put adds a new Route for PUT requests.

func (*Router) ServeHTTP

func (r *Router) ServeHTTP(rw http.ResponseWriter, req *http.Request)

Required by http.Handler interface. This method is invoked by the http server and will handle all page routing

func (*Router) Static

func (r *Router) Static(pattern string, dir string)

Adds a new Route for Static http requests. Serves static files from the specified directory

Jump to

Keyboard shortcuts

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