forked from tigergraph/Restifier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
40 lines (34 loc) · 802 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"github.com/Jeffail/gabs"
"github.com/gin-gonic/gin"
)
type response struct {
Error bool `json:"error"`
Message string `json:"message"`
Result interface{} `json:"result"`
}
func toJSON(stdout string) interface{} {
result, err := gabs.ParseJSON([]byte(stdout))
if err != nil {
return nil
}
return result.Data()
}
func main() {
r := gin.Default()
r.Use(authHandler)
api := r.Group("/api")
{
api.POST("/gsqlcmd", gsqlcmdHandler)
}
user := api.Group("/user")
{
user.GET("/profile", profileHandler)
user.POST("/create", createUserHandler)
user.POST("/drop", dropUserHandler)
user.POST("/grant", grantUserHandler)
user.POST("/revoke", revokeUserHandler)
}
r.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
}