diff --git a/server/README.md b/server/README.md index 49565b4a..2028e3e2 100644 --- a/server/README.md +++ b/server/README.md @@ -25,8 +25,8 @@ $ ./nebula-studio-server -studio-config="./config/example-config.yaml" | Name | Path | Method | | ------------------ | ------------------------- | -------- | -| ExecNGQL | /api-nebula/db/connect | POST | -| ConnectDB | /api-nebula/db/exec | POST | +| ExecNGQL | /api-nebula/db/exec | POST | +| ConnectDB | /api-nebula/db/connect | POST | | DisconnectDB | /api-nebula/db/disconnect | POST | | ImportData | /api-nebula/task/import | POST | | HandleImportAction | /api-nebula/import/action | POST | @@ -74,13 +74,13 @@ Response: ```json { - "code": 0, - "message": "", - "data": { - "nsid": "ae50dc65-0ef4-48f3-8f55-6a562a7e2ed7" - } + "code": 0, + "message": "", + "data": { + "nsid": "e870674d-6ebc-4d9d-a1f7-bf59fdca24e8", + "version": "v2.6" + } } - ``` #### DisconnectDB API diff --git a/server/go.mod b/server/go.mod index b65cfcda..300780c1 100644 --- a/server/go.mod +++ b/server/go.mod @@ -5,7 +5,7 @@ go 1.17 require ( github.com/kataras/iris/v12 v12.2.0-alpha4 github.com/mattn/go-sqlite3 v2.0.3+incompatible - github.com/vesoft-inc/nebula-http-gateway/ccore v0.0.0-20220119025135-9c14441ae6d0 + github.com/vesoft-inc/nebula-http-gateway/ccore v0.0.0-20220124093655-f7f5b4c63e6a github.com/vesoft-inc/nebula-importer v1.0.1-0.20211213064541-05a8646be295 go.uber.org/zap v1.17.0 gopkg.in/yaml.v2 v2.4.0 diff --git a/server/go.sum b/server/go.sum index 53ba4fd8..32867656 100644 --- a/server/go.sum +++ b/server/go.sum @@ -204,8 +204,8 @@ github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6Kllzaw github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/vesoft-inc/nebula-go/v2 v2.5.2-0.20211210024917-9461e07cdca2 h1:ivN82oSpM/kNCZVdzoCSj1IT4ZDW7Xi2juhAZvh7eF8= github.com/vesoft-inc/nebula-go/v2 v2.5.2-0.20211210024917-9461e07cdca2/go.mod h1:fehDUs97/mpmxXi9WezhznX0Dg7hmQRUoOWgDZv9zG0= -github.com/vesoft-inc/nebula-http-gateway/ccore v0.0.0-20220119025135-9c14441ae6d0 h1:hA8blKE64P2MbQcYlpqI0Lf28xpD2idmB+oCKoPXM78= -github.com/vesoft-inc/nebula-http-gateway/ccore v0.0.0-20220119025135-9c14441ae6d0/go.mod h1:sFEvE+cY4TgwqWx6H6msOqAUzRhsEHHKaaMgIZENHuQ= +github.com/vesoft-inc/nebula-http-gateway/ccore v0.0.0-20220124093655-f7f5b4c63e6a h1:tirwUK05V3LPsIFaLa0cHmVqFD3F1Tb8PlDTK7YWQGc= +github.com/vesoft-inc/nebula-http-gateway/ccore v0.0.0-20220124093655-f7f5b4c63e6a/go.mod h1:sFEvE+cY4TgwqWx6H6msOqAUzRhsEHHKaaMgIZENHuQ= github.com/vesoft-inc/nebula-importer v1.0.1-0.20211213064541-05a8646be295 h1:YdBNGn+5YyIuQ6cWjIPCvSJW/3qj5ck5UIWGeh4hXNI= github.com/vesoft-inc/nebula-importer v1.0.1-0.20211213064541-05a8646be295/go.mod h1:0nHCbr2/nckhfxAA8sDbwxkNzA9YyXazWKyVMT/PfPo= github.com/vmihailenco/msgpack/v5 v5.3.4 h1:qMKAwOV+meBw2Y8k9cVwAy7qErtYCwBzZ2ellBfvnqc= diff --git a/server/pkg/webserver/controller/gateway.go b/server/pkg/webserver/controller/gateway.go index e894ede3..edcc67ea 100644 --- a/server/pkg/webserver/controller/gateway.go +++ b/server/pkg/webserver/controller/gateway.go @@ -75,8 +75,10 @@ func ConnectDB(ctx iris.Context) base.Result { Message: err.Error(), } } - nsid, err := dao.Connect(params.Address, params.Port, params.Username, params.Password) - //sessions.Get(ctx).Set("nsid", nsid) + clientInfo, err := dao.Connect(params.Address, params.Port, params.Username, params.Password) + if err != nil { + return nil + } if err != nil { zap.L().Warn("connect DB fail", zap.Error(err)) return base.Response{ @@ -85,7 +87,10 @@ func ConnectDB(ctx iris.Context) base.Result { } } data := make(map[string]string) + nsid := clientInfo.ClientID + version := clientInfo.NebulaVersion data["nsid"] = nsid + data["version"] = string(version) ctx.SetCookieKV("nsid", nsid) return base.Response{ Code: base.Success,