fix #316
Showing
2 changed files
with
18 additions
and
6 deletions
| ... | @@ -11,14 +11,16 @@ import ( | ... | @@ -11,14 +11,16 @@ import ( |
| 11 | 11 | ||
| 12 | type BeegoInput struct { | 12 | type BeegoInput struct { |
| 13 | CruSession session.SessionStore | 13 | CruSession session.SessionStore |
| 14 | Param map[string]string | 14 | Params map[string]string |
| 15 | Data map[interface{}]interface{} | ||
| 15 | req *http.Request | 16 | req *http.Request |
| 16 | RequestBody []byte | 17 | RequestBody []byte |
| 17 | } | 18 | } |
| 18 | 19 | ||
| 19 | func NewInput(req *http.Request) *BeegoInput { | 20 | func NewInput(req *http.Request) *BeegoInput { |
| 20 | return &BeegoInput{ | 21 | return &BeegoInput{ |
| 21 | Param: make(map[string]string), | 22 | Params: make(map[string]string), |
| 23 | Data: make(map[interface{}]interface{}), | ||
| 22 | req: req, | 24 | req: req, |
| 23 | } | 25 | } |
| 24 | } | 26 | } |
| ... | @@ -129,8 +131,8 @@ func (input *BeegoInput) UserAgent() string { | ... | @@ -129,8 +131,8 @@ func (input *BeegoInput) UserAgent() string { |
| 129 | return input.Header("User-Agent") | 131 | return input.Header("User-Agent") |
| 130 | } | 132 | } |
| 131 | 133 | ||
| 132 | func (input *BeegoInput) Params(key string) string { | 134 | func (input *BeegoInput) Param(key string) string { |
| 133 | if v, ok := input.Param[key]; ok { | 135 | if v, ok := input.Params[key]; ok { |
| 134 | return v | 136 | return v |
| 135 | } | 137 | } |
| 136 | return "" | 138 | return "" |
| ... | @@ -164,3 +166,14 @@ func (input *BeegoInput) Body() []byte { | ... | @@ -164,3 +166,14 @@ func (input *BeegoInput) Body() []byte { |
| 164 | input.RequestBody = requestbody | 166 | input.RequestBody = requestbody |
| 165 | return requestbody | 167 | return requestbody |
| 166 | } | 168 | } |
| 169 | |||
| 170 | func (input *BeegoInput) GetData(key interface{}) interface{} { | ||
| 171 | if v, ok := input.Data[key]; ok { | ||
| 172 | return v | ||
| 173 | } | ||
| 174 | return nil | ||
| 175 | } | ||
| 176 | |||
| 177 | func (input *BeegoInput) SetData(key, val interface{}) { | ||
| 178 | input.Data[key] = val | ||
| 179 | } | ... | ... |
-
Please register or sign in to post a comment