mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 17:40:55 +00:00
fix multipart & add three useful function
c.GetString() c. GetInt() c.GetBool()
This commit is contained in:
parent
4353c98fd0
commit
f9e8b4f124
7
beego.go
7
beego.go
@ -35,6 +35,7 @@ var (
|
|||||||
SessionGCMaxLifetime int64 // session's gc maxlifetime
|
SessionGCMaxLifetime int64 // session's gc maxlifetime
|
||||||
SessionSavePath string // session savepath if use mysql/redis/file this set to the connectinfo
|
SessionSavePath string // session savepath if use mysql/redis/file this set to the connectinfo
|
||||||
UseFcgi bool
|
UseFcgi bool
|
||||||
|
MaxMemory int64
|
||||||
|
|
||||||
GlobalSessions *session.Manager //GlobalSessions
|
GlobalSessions *session.Manager //GlobalSessions
|
||||||
)
|
)
|
||||||
@ -62,6 +63,7 @@ func init() {
|
|||||||
SessionGCMaxLifetime = 3600
|
SessionGCMaxLifetime = 3600
|
||||||
SessionSavePath = ""
|
SessionSavePath = ""
|
||||||
UseFcgi = false
|
UseFcgi = false
|
||||||
|
MaxMemory = 1 << 26 //64MB
|
||||||
} else {
|
} else {
|
||||||
HttpAddr = AppConfig.String("httpaddr")
|
HttpAddr = AppConfig.String("httpaddr")
|
||||||
if v, err := AppConfig.Int("httpport"); err != nil {
|
if v, err := AppConfig.Int("httpport"); err != nil {
|
||||||
@ -69,6 +71,11 @@ func init() {
|
|||||||
} else {
|
} else {
|
||||||
HttpPort = v
|
HttpPort = v
|
||||||
}
|
}
|
||||||
|
if v, err := AppConfig.Int64("maxmemory"); err != nil {
|
||||||
|
MaxMemory = 1 << 26
|
||||||
|
} else {
|
||||||
|
MaxMemory = v
|
||||||
|
}
|
||||||
AppName = AppConfig.String("appname")
|
AppName = AppConfig.String("appname")
|
||||||
if runmode := AppConfig.String("runmode"); runmode != "" {
|
if runmode := AppConfig.String("runmode"); runmode != "" {
|
||||||
RunMode = runmode
|
RunMode = runmode
|
||||||
|
@ -170,10 +170,27 @@ func (c *Controller) ServeXml() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Controller) Input() url.Values {
|
func (c *Controller) Input() url.Values {
|
||||||
|
ct := c.Ctx.Request.Header.Get("Content-Type")
|
||||||
|
if ct == "multipart/form-data" {
|
||||||
|
c.Ctx.Request.ParseMultipartForm(MaxMemory) //64MB
|
||||||
|
} else {
|
||||||
c.Ctx.Request.ParseForm()
|
c.Ctx.Request.ParseForm()
|
||||||
|
}
|
||||||
return c.Ctx.Request.Form
|
return c.Ctx.Request.Form
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Controller) GetString(key string) string {
|
||||||
|
return c.Input().Get(key)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Controller) GetInt(key string) (int64, error) {
|
||||||
|
return strconv.ParseInt(c.Input().Get(key), 10, 64)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Controller) GetBool(key string) (bool, error) {
|
||||||
|
return strconv.ParseBool(c.Input().Get(key))
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Controller) StartSession() (sess session.SessionStore) {
|
func (c *Controller) StartSession() (sess session.SessionStore) {
|
||||||
sess = GlobalSessions.SessionStart(c.Ctx.ResponseWriter, c.Ctx.Request)
|
sess = GlobalSessions.SessionStart(c.Ctx.ResponseWriter, c.Ctx.Request)
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user