diff --git a/controllers/db.go b/controllers/db.go index 7f7ccd5c..b9968094 100644 --- a/controllers/db.go +++ b/controllers/db.go @@ -22,11 +22,10 @@ type Request struct { Username string `json:"username"` Password string `json:"password"` Address string `json:"address"` - Port int `json:"port"` + Port int `json:"port"` } type ExecuteRequest struct { - SessionID int64 `json:"sessionID"` Gql string `json:"gql"` } @@ -39,7 +38,13 @@ func (this *DatabaseController) Connect() { nsid, err := dao.Connect(params.Address, params.Port, params.Username, params.Password) if err == nil { res.Code = 0 + m := make(map[string]common.Any) + m["nsid"] = nsid + res.Data = nsid + this.Ctx.SetCookie("Secure","true") + this.Ctx.SetCookie("SameSite","None") this.SetSession("nsid", nsid) + res.Message = "Login successfully" } else { res.Code = -1 @@ -49,6 +54,12 @@ func (this *DatabaseController) Connect() { this.ServeJSON() } +func (this *DatabaseController) Home(){ + var res Response + res.Code = 0 + this.ServeJSON() +} + func (this *DatabaseController) Disconnect() { var res Response nsid := this.GetSession("nsid") diff --git a/routers/router.go b/routers/router.go index a6529bf6..36723b24 100644 --- a/routers/router.go +++ b/routers/router.go @@ -7,6 +7,7 @@ import ( ) func init() { + beego.Router("/", &controllers.DatabaseController{}, "*:Home") beego.Router("/api/db/connect", &controllers.DatabaseController{}, "POST:Connect") beego.Router("/api/db/exec", &controllers.DatabaseController{}, "POST:Execute") beego.Router("/api/db/disconnect", &controllers.DatabaseController{}, "POST:Disconnect") diff --git a/tmp/runner-build b/tmp/runner-build new file mode 100755 index 00000000..4fda1b4d Binary files /dev/null and b/tmp/runner-build differ