-
Notifications
You must be signed in to change notification settings - Fork 0
/
mux.go
76 lines (58 loc) · 1.35 KB
/
mux.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package gomple
import (
"net/http"
"github.com/go-chi/chi"
)
func NewMux(opts ...Option) *Mux {
return &Mux{
g: New(opts...),
mux: chi.NewMux(),
}
}
func NewMuxWithGomple(g *Gomple) *Mux {
return &Mux{
g: g,
mux: chi.NewMux(),
}
}
type Mux struct {
g *Gomple
mux *chi.Mux
}
var _ http.Handler = (*Mux)(nil)
func (m *Mux) Gomple() *Gomple {
return m.g
}
func (m *Mux) Raw() *chi.Mux {
return m.mux
}
func (m *Mux) ServeHTTP(w http.ResponseWriter, r *http.Request) {
m.mux.ServeHTTP(w, r)
}
func (m *Mux) Get(pattern string, h HandlerFunc) {
m.mux.Get(pattern, m.g.WrapFunc(h))
}
func (m *Mux) Put(pattern string, h HandlerFunc) {
m.mux.Put(pattern, m.g.WrapFunc(h))
}
func (m *Mux) Post(pattern string, h HandlerFunc) {
m.mux.Post(pattern, m.g.WrapFunc(h))
}
func (m *Mux) Options(pattern string, h HandlerFunc) {
m.mux.Options(pattern, m.g.WrapFunc(h))
}
func (m *Mux) Head(pattern string, h HandlerFunc) {
m.mux.Head(pattern, m.g.WrapFunc(h))
}
func (m *Mux) Delete(pattern string, h HandlerFunc) {
m.mux.Delete(pattern, m.g.WrapFunc(h))
}
func (m *Mux) Connect(pattern string, h HandlerFunc) {
m.mux.Connect(pattern, m.g.WrapFunc(h))
}
func (m *Mux) Trace(pattern string, h HandlerFunc) {
m.mux.Trace(pattern, m.g.WrapFunc(h))
}
func (m *Mux) HandleFunc(pattern string, h HandlerFunc) {
m.mux.HandleFunc(pattern, m.g.WrapFunc(h))
}