From 93f1e7e2f2ea5dfdad2b2b496342eeaebb5c442b Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Mon, 13 Oct 2014 12:22:50 +0800 Subject: [PATCH] =?UTF-8?q?HTTP=20=E4=BC=9A=E8=AF=9D=E5=A4=B1=E6=95=88?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/wide.go | 23 ++++++++++++----------- conf/wide.json | 1 + editor/editors.go | 3 ++- main.go | 8 +++++--- shell/shells.go | 1 + 5 files changed, 21 insertions(+), 15 deletions(-) diff --git a/conf/wide.go b/conf/wide.go index e34fcfe..42eb8ef 100644 --- a/conf/wide.go +++ b/conf/wide.go @@ -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 // 用户集 } // 配置. diff --git a/conf/wide.json b/conf/wide.json index 1b0f0d3..66248d9 100644 --- a/conf/wide.json +++ b/conf/wide.json @@ -5,6 +5,7 @@ "OutputChannel": "ws://{IP}:7070", "ShellChannel": "ws://{IP}:7070", "SessionChannel": "ws://{IP}:7070", + "HTTPSessionMaxAge": 86400, "StaticResourceVersion": "201409032040", "MaxProcs": 4, "RuntimeMode": "dev", diff --git a/editor/editors.go b/editor/editors.go index a6fe6b8..221ade6 100644 --- a/editor/editors.go +++ b/editor/editors.go @@ -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() diff --git a/main.go b/main.go index caf0bd3..1bb8fe1 100644 --- a/main.go +++ b/main.go @@ -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 会话 diff --git a/shell/shells.go b/shell/shells.go index dcd8607..6c92344 100644 --- a/shell/shells.go +++ b/shell/shells.go @@ -35,6 +35,7 @@ func IndexHandler(w http.ResponseWriter, r *http.Request) { return } + httpSession.Options.MaxAge = conf.Wide.HTTPSessionMaxAge httpSession.Save(r, w) // 创建一个 Wide 会话