httpmux

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2024 License: MIT Imports: 3 Imported by: 2

README

httpmux

Go Report Card GoDoc

httpmux wraps http.ServeMux with more features.

Usages

mux := httpmux.New()
mux.Handle("/path", handler) // /path

g := mux.Group("/group")
g.Handle("/path", handler) // /group/path
g.Handle("POST /path2", handler) // POST /group/path2

authed := mux.Middleware(authMiddleware)
authed.Handle("POST /get-orders", handler) // POST /get-orders with authMiddleware

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Middleware added in v1.1.0

type Middleware = func(http.Handler) http.Handler

type Mux

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

Mux type

func New

func New() *Mux

New creates new mux

func (*Mux) Group

func (m *Mux) Group(prefix string, middleware ...Middleware) *Mux

Group creates new group mux

func (*Mux) Handle

func (m *Mux) Handle(pattern string, handler http.Handler)

Handle registers handler into mux

func (*Mux) HandleFunc

func (m *Mux) HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))

HandleFunc registers handler into mux

func (*Mux) Middleware added in v1.1.0

func (m *Mux) Middleware(middleware ...Middleware) *Mux

Middleware creates new mux without prefix with middleware

func (*Mux) ServeHTTP

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

Jump to

Keyboard shortcuts

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