-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.go
executable file
·47 lines (41 loc) · 1.05 KB
/
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
47
package main
import (
"net/http"
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
"github.com/labstack/gommon/log"
"gitlab.odds.team/internship/macinodds-api/config"
route "gitlab.odds.team/internship/macinodds-api/routes"
)
func main() {
// Use labstack/echo for rich routing.
// See https://echo.labstack.com/
e := echo.New()
s := config.Spec()
// Middleware
e.Logger.SetLevel(log.ERROR)
e.Use(
middleware.CORS(),
middleware.Recover(),
middleware.Logger(),
middleware.JWTWithConfig(middleware.JWTConfig{
SigningKey: []byte("sMJuczqQPYzocl1s6SLj"),
Skipper: func(c echo.Context) bool {
// Skip authentication for and login requests
if c.Path() == "/login" || c.Path() == "/_ah/health" {
return true
}
return false
},
}),
)
// Respond to API health checks.
// Indicate the server is healthy.
e.GET("/_ah/health", func(c echo.Context) error {
return c.String(http.StatusOK, "mac.odds.team : ok!")
})
// Initialize routes
route.Init(e)
// Start server
e.Logger.Fatal(e.Start(s.APIPort))
}