router

package
v0.5.8 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2023 License: MIT Imports: 8 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Debug   bool
	Limiter struct {
		Rps     float64
		Burst   int
		Enabled bool
	}
	CORS struct {
		TrustedOrigins []string
	}
	Metrics bool
}

Config is the configuration for the router

func DefaultConf

func DefaultConf() *Config

DefaultConf return the default config

type Handler added in v0.4.3

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

Handler serveHTTP

func (Handler) ServeHTTP added in v0.4.3

func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Router added in v0.2.0

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

Router ..

func NewRouter added in v0.2.0

func NewRouter(c *Config) *Router

func (*Router) Delete added in v0.2.0

func (r *Router) Delete(path string, handler http.HandlerFunc)

Delete is a shortcut for HandleFunc(http.MethodDelete, path, handler)

func (*Router) Get added in v0.2.0

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

Get is a shortcut for HandleFunc(http.MethodGet, path, handler)

func (*Router) Handle added in v0.2.0

func (r *Router) Handle(method, path string, h http.Handler)

func (*Router) HandleFunc added in v0.2.0

func (r *Router) HandleFunc(method, path string, hf http.HandlerFunc)

func (*Router) Handler added in v0.4.3

func (ro *Router) Handler() Handler

func (*Router) Patch added in v0.2.0

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

Patch is a shortcut for HandleFunc(http.MethodPatch, path, handler)

func (*Router) Post added in v0.2.0

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

Post is a shortcut for HandleFunc(http.MethodPost, path, handler)

func (*Router) Put added in v0.2.0

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

Put is a shortcut for HandleFunc(http.MethodPut, path, handler)

func (*Router) ServeFS added in v0.4.15

func (r *Router) ServeFS(path string, root http.FileSystem, mds ...handler.Middleware)

func (*Router) ServeFSWithGzip added in v0.4.15

func (r *Router) ServeFSWithGzip(path string, root http.FileSystem, mds ...handler.Middleware)

func (*Router) Static added in v0.2.0

func (r *Router) Static(path string, dst string, mds ...handler.Middleware)

Static serve dir dest

func (*Router) StaticGZIP added in v0.3.2

func (r *Router) StaticGZIP(path string, dst string, mds ...handler.Middleware)

StaticGZIP serve dir dest with Gzip middleware

type RoutesGroup

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

RoutesGroup is a group of routes

func DefaultRoutesGroup added in v0.0.15

func DefaultRoutesGroup() *RoutesGroup

DefaultRoutesGroup return a new routesgroup with default router config

func NewRoutesGroup added in v0.0.15

func NewRoutesGroup(conf *Config) (*RoutesGroup, error)

NewRoutesGroup return a new routesgroup

func (*RoutesGroup) Delete

func (g *RoutesGroup) Delete(path string, handler http.HandlerFunc)

Delete is a shortcut for NewHandler(http.MethodDelete, path, handler)

func (*RoutesGroup) Get

func (g *RoutesGroup) Get(path string, handler http.HandlerFunc)

Get is a shortcut for NewHandler(http.MethodGet, path, handler)

func (*RoutesGroup) Group

func (g *RoutesGroup) Group(path string, mds ...handler.Middleware) *RoutesGroup

Group add a prefix to all path, for each Gropu call prefix and middleware will accumulate

func (*RoutesGroup) HandleFunc added in v0.2.0

func (g *RoutesGroup) HandleFunc(method, path string, handler http.HandlerFunc)

HandleFunc handle new http request

func (*RoutesGroup) Handler added in v0.4.3

func (g *RoutesGroup) Handler() Handler

Handler return http.Handler

func (*RoutesGroup) Patch

func (g *RoutesGroup) Patch(path string, handler http.HandlerFunc)

Patch is a shortcut for NewHandler(http.MethodPatch, path, handler)

func (*RoutesGroup) Post

func (g *RoutesGroup) Post(path string, handler http.HandlerFunc)

Post is a shortcut for NewHandler(http.MethodPost, path, handler)

func (*RoutesGroup) Put

func (g *RoutesGroup) Put(path string, handler http.HandlerFunc)

Put is a shortcut for NewHandler(http.MethodPut, path, handler)

func (*RoutesGroup) ServeFS added in v0.4.15

func (g *RoutesGroup) ServeFS(path string, root http.FileSystem)

ServerFs ...

func (*RoutesGroup) ServeFSWithGzip added in v0.4.15

func (g *RoutesGroup) ServeFSWithGzip(path string, root http.FileSystem)

ServFSWithGzip ...

func (*RoutesGroup) Static

func (g *RoutesGroup) Static(path string, dst string)

Static serve dir dest

func (*RoutesGroup) StaticGZIP added in v0.3.2

func (g *RoutesGroup) StaticGZIP(path string, dst string)

StaticGZIP serve dir dest with Gzip middleware

func (*RoutesGroup) Use

func (g *RoutesGroup) Use(mds ...handler.Middleware)

Use add middleware to the group middleware will be called in the order of use Or call NewHandler to add a new middleware

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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