HTTP 会话失效配置

This commit is contained in:
Liang Ding 2014-10-13 12:22:50 +08:00
parent 68eb5a1bc3
commit 93f1e7e2f2
5 changed files with 21 additions and 15 deletions

View File

@ -34,17 +34,18 @@ type User struct {
// 配置结构. // 配置结构.
type conf struct { type conf struct {
Server string Server string // 服务地址({IP}:7070
StaticServer string StaticServer string // 静态资源服务地址http://{IP}:7070
EditorChannel string EditorChannel string // 编辑器通道地址ws://{IP}:7070
OutputChannel string OutputChannel string // 输出窗口通道地址ws://{IP}:7070
ShellChannel string ShellChannel string // Shell 通道地址ws://{IP}:7070
SessionChannel string SessionChannel string // Wide 会话通道地址ws://{IP}:7070
StaticResourceVersion string HTTPSessionMaxAge int // HTTP 会话失效时间(秒)
MaxProcs int StaticResourceVersion string // 静态资源版本
RuntimeMode string MaxProcs int // 并发执行数
Pwd string RuntimeMode string // 运行模式
Users []*User Pwd string // 工作目录
Users []*User // 用户集
} }
// 配置. // 配置.

View File

@ -5,6 +5,7 @@
"OutputChannel": "ws://{IP}:7070", "OutputChannel": "ws://{IP}:7070",
"ShellChannel": "ws://{IP}:7070", "ShellChannel": "ws://{IP}:7070",
"SessionChannel": "ws://{IP}:7070", "SessionChannel": "ws://{IP}:7070",
"HTTPSessionMaxAge": 86400,
"StaticResourceVersion": "201409032040", "StaticResourceVersion": "201409032040",
"MaxProcs": 4, "MaxProcs": 4,
"RuntimeMode": "dev", "RuntimeMode": "dev",

View File

@ -275,7 +275,8 @@ func FindDeclarationHandler(w http.ResponseWriter, r *http.Request) {
ch := int(args["cursorCh"].(float64)) ch := int(args["cursorCh"].(float64))
offset := getCursorOffset(code, line, ch) offset := getCursorOffset(code, line, ch)
glog.Infof("offset [%d]", offset)
// glog.Infof("offset [%d]", offset)
// TODO: 目前是调用 liteide_stub 工具来查找声明,后续需要重新实现 // TODO: 目前是调用 liteide_stub 工具来查找声明,后续需要重新实现
ide_stub := conf.Wide.GetIDEStub() ide_stub := conf.Wide.GetIDEStub()

View File

@ -23,8 +23,9 @@ import (
"github.com/golang/glog" "github.com/golang/glog"
) )
// 当前 Wide 版本. const (
const Ver = "1.0.0-dev" Ver = "1.0.0-dev" // 当前 Wide 版本
)
// Wide 中唯一一个 init 函数. // Wide 中唯一一个 init 函数.
func init() { func init() {
@ -104,7 +105,7 @@ func loginHandler(w http.ResponseWriter, r *http.Request) {
httpSession, _ := session.HTTPSession.Get(r, "wide-session") httpSession, _ := session.HTTPSession.Get(r, "wide-session")
httpSession.Values["username"] = args.Username httpSession.Values["username"] = args.Username
httpSession.Values["id"] = strconv.Itoa(rand.Int()) httpSession.Values["id"] = strconv.Itoa(rand.Int())
httpSession.Options.MaxAge = 60 * 60 * 24 // 一天过期 httpSession.Options.MaxAge = conf.Wide.HTTPSessionMaxAge
httpSession.Save(r, w) httpSession.Save(r, w)
glog.Infof("Created a HTTP session [%s] for user [%s]", httpSession.Values["id"].(string), args.Username) glog.Infof("Created a HTTP session [%s] for user [%s]", httpSession.Values["id"].(string), args.Username)
@ -122,6 +123,7 @@ func indexHandler(w http.ResponseWriter, r *http.Request) {
return return
} }
httpSession.Options.MaxAge = conf.Wide.HTTPSessionMaxAge
httpSession.Save(r, w) httpSession.Save(r, w)
// 创建一个 Wide 会话 // 创建一个 Wide 会话

View File

@ -35,6 +35,7 @@ func IndexHandler(w http.ResponseWriter, r *http.Request) {
return return
} }
httpSession.Options.MaxAge = conf.Wide.HTTPSessionMaxAge
httpSession.Save(r, w) httpSession.Save(r, w)
// 创建一个 Wide 会话 // 创建一个 Wide 会话