-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.go
46 lines (35 loc) · 857 Bytes
/
server.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
41
42
43
44
45
46
package main
import (
"log"
"github.com/gin-gonic/gin"
"github.com/harlov/letitbe/db"
"github.com/harlov/letitbe/sessions"
"github.com/harlov/letitbe/users"
)
func main() {
var err error
log.Print("letitbe init...")
err = db.Init()
if err != nil {
log.Fatal("db connect error. break")
return
}
log.Println("db inited...")
createServer()
}
func createServer() {
r := gin.Default()
router := r.Group("/v1")
r.GET("/", rootAction)
setupRoutes(router)
r.Run(":8080")
}
func setupRoutes(router *gin.RouterGroup) {
user_router := router.Group("/user")
session_router := router.Group("/session")
users.SetupRoutes(user_router)
sessions.SetupRoutes(session_router)
}
func rootAction(c *gin.Context) {
c.String(200, "Auth&permissions microservice")
}