diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..b4195bb --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +insert_final_newline = true +charset = utf-8 +trim_trailing_whitespace = true +indent_style = space +indent_size = 2 + +[{Makefile,go.mod,go.sum,*.go}] +indent_style = tab +indent_size = 2 diff --git a/.gitignore b/.gitignore index b07a1b1..2e5d344 100644 --- a/.gitignore +++ b/.gitignore @@ -15,5 +15,4 @@ nebula-httpd vendor/ # Dependency directories (remove the comment below to include it) -# vendor/ -tmp/* +tmp/ diff --git a/Makefile b/Makefile index 45b3b9e..b4ff00c 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,3 @@ - .PHONY: build clean fmt default: build @@ -6,8 +5,8 @@ default: build clean: @go mod tidy && rm -rf nebula-httpd -build: clean fmt - @go build -o nebula-httpd main.go - fmt: @find . -type f -iname \*.go -exec go fmt {} \; + +build: clean fmt + @go build -o nebula-httpd main.go diff --git a/README.md b/README.md index a133e8f..ea5d78f 100644 --- a/README.md +++ b/README.md @@ -23,11 +23,11 @@ $ ./nebula-httpd ## User Guide #### API Definition -| Name | Path | Method | -| --- | --- | --- | -| connect | /api/db/connect | POST | -| exec | /api/db/exec | POST | -| disconnect | /api/db/disconnect | POST | +| Name | Path | Method | +|------------|--------------------|--------| +| connect | /api/db/connect | POST | +| exec | /api/db/exec | POST | +| disconnect | /api/db/disconnect | POST | > Connect API @@ -42,12 +42,12 @@ The requested json body ``` The description of the parameters is as follows. -| Field | Description | -| --- | --- | +| Field | Description | +|----------|-----------------------------------------------------------------------------------------------------------------------------| | username | Sets the username of your Nebula Graph account. Before enabling authentication, you can use any characters as the username. | | password | Sets the password of your Nebula Graph account. Before enabling authentication, you can use any characters as the password. | -| address | Sets the IP address of the graphd service. | -| port | Sets the port number of the graphd service. The default port number is 9669. | +| address | Sets the IP address of the graphd service. | +| port | Sets the port number of the graphd service. The default port number is 9669. | ```bash $ curl -i -X POST -d '{"username":"user","password":"password","address":"192.168.8.26","port":9669}' http://127.0.0.1:8080/api/db/connect @@ -67,10 +67,10 @@ Date: Fri, 02 Apr 2021 08:49:18 GMT } ``` -Notice: +Notice: -The response data nsid "5e18fa40-5343-422f-84e3-e7f9cad6b735" is encoded by HMAC-SH256 encryption algorithm,so it's not the same as what you get from a cookie. -If you connect the graphd service succeed, remember to save the *NSID*, it's important for the *exec api* to execute nGQL. +The response data nsid "5e18fa40-5343-422f-84e3-e7f9cad6b735" is encoded by HMAC-SH256 encryption algorithm,so it's not the same as what you get from a cookie. +If you connect the graphd service succeed, remember to save the *NSID*, it's important for the *exec api* to execute nGQL. If you restart the gateway server, all authenticated session will be lost, please noticed. > Exec API diff --git a/tests/controller/db_test.go b/controllers/db_test.go similarity index 100% rename from tests/controller/db_test.go rename to controllers/db_test.go diff --git a/go.sum b/go.sum index 81e2878..ba5c01b 100644 --- a/go.sum +++ b/go.sum @@ -328,8 +328,6 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1 github.com/ugorji/go v0.0.0-20171122102828-84cb69a8af83/go.mod h1:hnLbHMwcvSihnDhEfx2/BzKp2xb0Y+ErdfYcrs9tkJQ= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= -github.com/vesoft-inc/nebula-go/v2 v2.0.0-20210603033436-24ea78f90a1e h1:B53wGI1tbj/QP2nPm+ubQx/3UTmf4gMhmCVqndfis/o= -github.com/vesoft-inc/nebula-go/v2 v2.0.0-20210603033436-24ea78f90a1e/go.mod h1:B7nR6+nOSo0umq/HkCmUfyRtYrJVOsNiPS9u4djDbSc= github.com/vesoft-inc/nebula-go/v2 v2.0.0-20210709070507-5ab4bdcd57db h1:I22+tDn3oRUPAyhLgjwteYE8ZmZDJZfkQEBHyGiosKo= github.com/vesoft-inc/nebula-go/v2 v2.0.0-20210709070507-5ab4bdcd57db/go.mod h1:B7nR6+nOSo0umq/HkCmUfyRtYrJVOsNiPS9u4djDbSc= github.com/wendal/errors v0.0.0-20130201093226-f66c77a7882b/go.mod h1:Q12BUT7DqIlHRmgv3RskH+UCM/4eqVMgI0EMmlSpAXc= diff --git a/tmp/runner-build b/tmp/runner-build deleted file mode 100755 index 8d11e85..0000000 Binary files a/tmp/runner-build and /dev/null differ