-
Notifications
You must be signed in to change notification settings - Fork 0
/
requestcontext.go
65 lines (55 loc) · 1.36 KB
/
requestcontext.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
package mano
import (
"net/http"
"github.com/junhwong/mano/utils"
)
type RequestContext struct {
response *Response
request *Request
app *Application
routeData *RouteData
attrs utils.Attribute
data utils.Attribute
local string
}
func newRequestContext(app *Application, request *http.Request, writer http.ResponseWriter, routeData *RouteData) *RequestContext {
return &RequestContext{
response: &Response{
Response: request.Response,
writer: writer,
},
request: &Request{
Request: request,
},
app: app,
routeData: routeData,
attrs: make(utils.Attribute),
data: make(utils.Attribute),
}
}
func (ctx *RequestContext) App() *Application {
return ctx.app
}
func (ctx *RequestContext) ViewData() map[string]interface{} {
return ctx.data
}
func (ctx *RequestContext) Response() *Response {
return ctx.response
}
func (ctx *RequestContext) Request() *Request {
return ctx.request
}
func (ctx *RequestContext) Attr(name string, value ...interface{}) interface{} {
return ctx.attrs.Item(name, value...)
}
func (ctx *RequestContext) Data(name string, value ...interface{}) interface{} {
return ctx.data.Item(name, value...)
}
func (ctx *RequestContext) PathValue(name string) (value string, ok bool) {
value = ""
ok = false
return
}
func (ctx *RequestContext) Param(name string) string {
return "nil"
}