router

package
v0.0.0-...-4a47c63 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HandlerFunc

type HandlerFunc func(http.ResponseWriter, *http.Request) (int, error)

HandlerFunc is used to wrapper all endpoint functions so they work with generic routers.

type Mux

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

Mux contains the router.

func New

func New(csh func(w http.ResponseWriter, r *http.Request, status int, err error), notFound http.Handler) *Mux

New returns an instance of the router.

func (*Mux) BadRequest

func (m *Mux) BadRequest(w http.ResponseWriter, r *http.Request)

BadRequest shows the 400 page.

func (*Mux) Delete

func (m *Mux) Delete(path string, fn HandlerFunc)

Delete is a shortcut for router.Handle("DELETE", path, handle)

func (*Mux) Get

func (m *Mux) Get(path string, fn HandlerFunc)

Get registers handler on path for both GET and HEAD verbs

func (*Mux) Head

func (m *Mux) Head(path string, fn HandlerFunc)

Head is a shortcut for router.Handle("HEAD", path, handle)

func (*Mux) NotFound

func (m *Mux) NotFound(w http.ResponseWriter, r *http.Request)

NotFound shows the 404 page.

func (*Mux) Options

func (m *Mux) Options(path string, fn HandlerFunc)

Options is a shortcut for router.Handle("OPTIONS", path, handle)

func (*Mux) Param

func (m *Mux) Param(r *http.Request, param string) string

Param returns a URL parameter.

func (*Mux) Patch

func (m *Mux) Patch(path string, fn HandlerFunc)

Patch is a shortcut for router.Handle("PATCH", path, handle)

func (*Mux) Post

func (m *Mux) Post(path string, fn HandlerFunc)

Post is a shortcut for router.Handle("POST", path, handle)

func (*Mux) Put

func (m *Mux) Put(path string, fn HandlerFunc)

Put is a shortcut for router.Handle("PUT", path, handle)

func (*Mux) ServeHTTP

func (m *Mux) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP routes the incoming http.Request based on method and path extracting path parameters as it goes.

Jump to

Keyboard shortcuts

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