Documentation
¶
Index ¶
- type Mux
- func (m *Mux) CONNECT(pattern string, h http.HandlerFunc)
- func (m *Mux) DELETE(pattern string, h http.HandlerFunc, mw ...func(http.Handler) http.Handler)
- func (m *Mux) GET(pattern string, h http.HandlerFunc, mw ...func(http.Handler) http.Handler)
- func (m *Mux) Group(fn func(grp *Mux))
- func (m *Mux) HEAD(pattern string, h http.HandlerFunc, mw ...func(http.Handler) http.Handler)
- func (m *Mux) HttpServeMux() *http.ServeMux
- func (m *Mux) OPTIONS(pattern string, h http.HandlerFunc)
- func (m *Mux) PATCH(pattern string, h http.HandlerFunc, mw ...func(http.Handler) http.Handler)
- func (m *Mux) POST(pattern string, h http.HandlerFunc, mw ...func(http.Handler) http.Handler)
- func (m *Mux) PUT(pattern string, h http.HandlerFunc, mw ...func(http.Handler) http.Handler)
- func (m *Mux) PrintRoutes(w io.Writer)
- func (m *Mux) Resource(pattern string, fn func(res *Resource), mw ...func(http.Handler) http.Handler)
- func (m *Mux) RouteList() []string
- func (m *Mux) Serve(cb ServeCB)
- func (m *Mux) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (m *Mux) TRACE(pattern string, h http.HandlerFunc)
- func (m *Mux) Use(h ...func(http.Handler) http.Handler)
- func (m *Mux) With(mw ...func(http.Handler) http.Handler) *Mux
- type Resource
- func (res *Resource) Create(h http.HandlerFunc)
- func (res *Resource) CreateView(h http.HandlerFunc)
- func (res *Resource) DELETE(pattern string, h http.HandlerFunc)
- func (res *Resource) Delete(h http.HandlerFunc)
- func (res *Resource) GET(pattern string, h http.HandlerFunc)
- func (res *Resource) Index(h http.HandlerFunc)
- func (res *Resource) MemberDELETE(pattern string, h http.HandlerFunc)
- func (res *Resource) MemberGET(pattern string, h http.HandlerFunc)
- func (res *Resource) MemberPATCH(pattern string, h http.HandlerFunc)
- func (res *Resource) MemberPOST(pattern string, h http.HandlerFunc)
- func (res *Resource) MemberPUT(pattern string, h http.HandlerFunc)
- func (res *Resource) PATCH(pattern string, h http.HandlerFunc)
- func (res *Resource) POST(pattern string, h http.HandlerFunc)
- func (res *Resource) PUT(pattern string, h http.HandlerFunc)
- func (res *Resource) Update(h http.HandlerFunc)
- func (res *Resource) UpdatePartial(h http.HandlerFunc)
- func (res *Resource) Use(middlewares ...func(http.Handler) http.Handler)
- func (res *Resource) View(h http.HandlerFunc)
- type RouteList
- type ServeCB
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Mux ¶ added in v0.5.0
Mux is a wrapper around the go's standard http.ServeMux. It's a lean wrapper with methods to make routing easier
func (*Mux) CONNECT ¶ added in v0.5.0
func (m *Mux) CONNECT(pattern string, h http.HandlerFunc)
CONNECT method route
func (*Mux) Group ¶ added in v0.5.0
Group adds a new inline-Router along the current routing path, with a fresh middleware stack for the inline-Router.
func (*Mux) HttpServeMux ¶ added in v0.5.0
HttpServeMux DO NOT USE it for routing, exposed only for edge cases.
func (*Mux) OPTIONS ¶ added in v0.5.0
func (m *Mux) OPTIONS(pattern string, h http.HandlerFunc)
OPTIONS method route
func (*Mux) PrintRoutes ¶ added in v0.5.0
func (*Mux) Resource ¶ added in v0.5.0
func (m *Mux) Resource(pattern string, fn func(res *Resource), mw ...func(http.Handler) http.Handler)
Resource routes mapping by using HTTP verbs
- GET /pattern view all resources
- GET /pattern/create new resource view
- POST /pattern create a new resource
- GET /pattern/{id} view a resource
- PUT /pattern/{id} update a resource
- PATCH /pattern/{id} partial update a resource
- DELETE /resource/{id} delete a resource
func (*Mux) ServeHTTP ¶ added in v0.5.0
func (m *Mux) ServeHTTP(w http.ResponseWriter, req *http.Request)
func (*Mux) TRACE ¶ added in v0.5.0
func (m *Mux) TRACE(pattern string, h http.HandlerFunc)
TRACE method route
type Resource ¶
type Resource struct {
// contains filtered or unexported fields
}
func (*Resource) Create ¶
func (res *Resource) Create(h http.HandlerFunc)
Create a new resource
POST /pattern/create
func (*Resource) CreateView ¶ added in v0.5.0
func (res *Resource) CreateView(h http.HandlerFunc)
CreateView new resource
GET /pattern/create
func (*Resource) DELETE ¶ added in v1.0.0
func (res *Resource) DELETE(pattern string, h http.HandlerFunc)
DELETE registers a custom DELETE route at collection level
DELETE /pattern/route
func (*Resource) Delete ¶ added in v0.5.0
func (res *Resource) Delete(h http.HandlerFunc)
Delete a resource
DELETE /pattern/{id}
func (*Resource) GET ¶ added in v1.0.0
func (res *Resource) GET(pattern string, h http.HandlerFunc)
GET registers a custom GET route at collection level
GET /pattern/route
func (*Resource) Index ¶
func (res *Resource) Index(h http.HandlerFunc)
Index of all resource.
GET /pattern
func (*Resource) MemberDELETE ¶ added in v1.0.0
func (res *Resource) MemberDELETE(pattern string, h http.HandlerFunc)
MemberDELETE registers a custom DELETE route at member level
DELETE /pattern/{id}/route
func (*Resource) MemberGET ¶ added in v1.0.0
func (res *Resource) MemberGET(pattern string, h http.HandlerFunc)
MemberGET registers a custom GET route at member level
GET /pattern/{id}/route
func (*Resource) MemberPATCH ¶ added in v1.0.0
func (res *Resource) MemberPATCH(pattern string, h http.HandlerFunc)
MemberPATCH registers a custom PATCH route at member level
PATCH /pattern/{id}/route
func (*Resource) MemberPOST ¶ added in v1.0.0
func (res *Resource) MemberPOST(pattern string, h http.HandlerFunc)
MemberPOST registers a custom POST route at member level
POST /pattern/{id}/route
func (*Resource) MemberPUT ¶ added in v1.0.0
func (res *Resource) MemberPUT(pattern string, h http.HandlerFunc)
MemberPUT registers a custom PUT route at member level
PUT /pattern/{id}/route
func (*Resource) PATCH ¶ added in v1.0.0
func (res *Resource) PATCH(pattern string, h http.HandlerFunc)
PATCH registers a custom PATCH route at collection level
PATCH /pattern/route
func (*Resource) POST ¶ added in v1.0.0
func (res *Resource) POST(pattern string, h http.HandlerFunc)
POST registers a custom POST route at collection level
POST /pattern/route
func (*Resource) PUT ¶ added in v1.0.0
func (res *Resource) PUT(pattern string, h http.HandlerFunc)
PUT registers a custom PUT route at collection level
PUT /pattern/route
func (*Resource) Update ¶
func (res *Resource) Update(h http.HandlerFunc)
Update a resource
PUT /pattern/{id}
func (*Resource) UpdatePartial ¶ added in v0.5.0
func (res *Resource) UpdatePartial(h http.HandlerFunc)
UpdatePartial resource info PATCH /pattern/{id}
func (*Resource) View ¶ added in v0.5.0
func (res *Resource) View(h http.HandlerFunc)
View a resource
GET /pattern/{id}