mirror of
https://github.com/astaxie/beego.git
synced 2024-11-26 06:01:29 +00:00
fix #316
This commit is contained in:
parent
7b405e9af7
commit
ae2e25f4c2
@ -1,9 +1,8 @@
|
|||||||
package context
|
package context
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/astaxie/beego/middleware"
|
"github.com/astaxie/beego/middleware"
|
||||||
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Context struct {
|
type Context struct {
|
||||||
|
@ -11,14 +11,16 @@ import (
|
|||||||
|
|
||||||
type BeegoInput struct {
|
type BeegoInput struct {
|
||||||
CruSession session.SessionStore
|
CruSession session.SessionStore
|
||||||
Param map[string]string
|
Params map[string]string
|
||||||
|
Data map[interface{}]interface{}
|
||||||
req *http.Request
|
req *http.Request
|
||||||
RequestBody []byte
|
RequestBody []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewInput(req *http.Request) *BeegoInput {
|
func NewInput(req *http.Request) *BeegoInput {
|
||||||
return &BeegoInput{
|
return &BeegoInput{
|
||||||
Param: make(map[string]string),
|
Params: make(map[string]string),
|
||||||
|
Data: make(map[interface{}]interface{}),
|
||||||
req: req,
|
req: req,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -129,8 +131,8 @@ func (input *BeegoInput) UserAgent() string {
|
|||||||
return input.Header("User-Agent")
|
return input.Header("User-Agent")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (input *BeegoInput) Params(key string) string {
|
func (input *BeegoInput) Param(key string) string {
|
||||||
if v, ok := input.Param[key]; ok {
|
if v, ok := input.Params[key]; ok {
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
@ -164,3 +166,14 @@ func (input *BeegoInput) Body() []byte {
|
|||||||
input.RequestBody = requestbody
|
input.RequestBody = requestbody
|
||||||
return requestbody
|
return requestbody
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (input *BeegoInput) GetData(key interface{}) interface{} {
|
||||||
|
if v, ok := input.Data[key]; ok {
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (input *BeegoInput) SetData(key, val interface{}) {
|
||||||
|
input.Data[key] = val
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user