router

package
v0.0.0-...-c1b8ff3 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Assets

type Assets struct {
	Path string
}

type Body

type Body struct {
	BodyDecoder *json.Decoder
}

type Context

type Context struct {
	Params *Params

	Body *json.Decoder
}

func (*Context) NewBodyDecoder

func (c *Context) NewBodyDecoder(reader io.ReadCloser)

type Handler

type Handler struct {
	Router *Router
}

func NewRouter

func NewRouter(prefix string) *Handler

func (*Handler) ASSETS

func (h *Handler) ASSETS(path string)

func (*Handler) DELETE

func (h *Handler) DELETE(path string, handler func(ctx *Context, w http.ResponseWriter, r *http.Request))

func (*Handler) GET

func (h *Handler) GET(path string, handler func(ctx *Context, w http.ResponseWriter, r *http.Request))

func (*Handler) PATCH

func (h *Handler) PATCH(path string, handler func(ctx *Context, w http.ResponseWriter, r *http.Request))

func (*Handler) POST

func (h *Handler) POST(path string, handler func(ctx *Context, w http.ResponseWriter, r *http.Request))

func (*Handler) PUT

func (h *Handler) PUT(path string, handler func(ctx *Context, w http.ResponseWriter, r *http.Request))

func (Handler) ServeHTTP

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

type IHandler

type IHandler interface {
	ServeHTTP(http.ResponseWriter, *http.Request)

	GET(path string, handler func(ctx *Context, w http.ResponseWriter, r *http.Request))
	POST(path string, handler func(ctx *Context, w http.ResponseWriter, r *http.Request))
	PATCH(path string, handler func(ctx *Context, w http.ResponseWriter, r *http.Request))
	PUT(path string, handler func(ctx *Context, w http.ResponseWriter, r *http.Request))
	DELETE(path string, handler func(ctx *Context, w http.ResponseWriter, r *http.Request))
}

type Node

type Node struct {
	Path     string
	FullPath string

	Handlers map[string]func(*Context, http.ResponseWriter, *http.Request)
	Children map[string]*Node
}

type Params

type Params struct {
	Values map[string][]string
}

func (*Params) Get

func (p *Params) Get(key string) []string

type Route

type Route struct {
	Method string
	Path   string
}

type Router

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

func (*Router) Add

func (r *Router) Add(method, path string, handler func(*Context, http.ResponseWriter, *http.Request))

func (*Router) Iterate

func (r *Router) Iterate() []*Route

Jump to

Keyboard shortcuts

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