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

View File

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

View File

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

View File

@ -23,8 +23,9 @@ import (
"github.com/golang/glog"
)
// 当前 Wide 版本.
const Ver = "1.0.0-dev"
const (
Ver = "1.0.0-dev" // 当前 Wide 版本
)
// Wide 中唯一一个 init 函数.
func init() {
@ -104,7 +105,7 @@ func loginHandler(w http.ResponseWriter, r *http.Request) {
httpSession, _ := session.HTTPSession.Get(r, "wide-session")
httpSession.Values["username"] = args.Username
httpSession.Values["id"] = strconv.Itoa(rand.Int())
httpSession.Options.MaxAge = 60 * 60 * 24 // 一天过期
httpSession.Options.MaxAge = conf.Wide.HTTPSessionMaxAge
httpSession.Save(r, w)
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
}
httpSession.Options.MaxAge = conf.Wide.HTTPSessionMaxAge
httpSession.Save(r, w)
// 创建一个 Wide 会话

View File

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