router

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2023 License: CC0-1.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const Version = "0.1.0"

Variables

This section is empty.

Functions

func Param

func Param(req *http.Request, name string) (string, bool)

URLParam extracts a parameter from the URL by name

func ParamInt

func ParamInt(req *http.Request, name string) (int, bool)

todo/check: change to ParamUint - why? why not?

func Query

func Query(req *http.Request, name string) (string, bool)

func QueryBool

func QueryBool(req *http.Request, name string) (bool, bool)

func QueryInt

func QueryInt(req *http.Request, name string) (int, bool)

todo/check: change to QueryUint - why? why not?

Types

type Route

type Route struct {
	Method  string
	Pattern *regexp.Regexp //  change to regex/re/rx or path or ___?
	Handler http.HandlerFunc
}

type Router

type Router struct {
	Routes []Route
}

func (*Router) Add

func (r *Router) Add(route Route)

func (*Router) GET

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

func (*Router) ServeHTTP

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

Jump to

Keyboard shortcuts

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