-
Notifications
You must be signed in to change notification settings - Fork 0
/
controller.go
51 lines (40 loc) · 899 Bytes
/
controller.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
package lightning
type ControllerInterface interface {
Handle(next Handler) Handler
DELETE(ctx *Context)
GET(ctx *Context)
HEAD(ctx *Context)
OPTIONS(ctx *Context)
PATCH(ctx *Context)
POST(ctx *Context)
PUT(ctx *Context)
}
type Controller struct {
}
func (c Controller) Handle(next Handler) Handler {
return HandlerFunc(func(ctx *Context) {
// Invoke the request handler.
next.Handle(ctx)
})
}
func (c Controller) DELETE(ctx *Context) {
ctx.ResponseForbidden()
}
func (c Controller) GET(ctx *Context) {
ctx.ResponseForbidden()
}
func (c Controller) HEAD(ctx *Context) {
ctx.ResponseForbidden()
}
func (c Controller) OPTIONS(ctx *Context) {
ctx.ResponseForbidden()
}
func (c Controller) PATCH(ctx *Context) {
ctx.ResponseForbidden()
}
func (c Controller) POST(ctx *Context) {
ctx.ResponseForbidden()
}
func (c Controller) PUT(ctx *Context) {
ctx.ResponseForbidden()
}