-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
48 lines (37 loc) · 1.01 KB
/
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
41
42
43
44
45
46
47
48
package main
import (
"github.com/iris-contrib/middleware/cors"
"github.com/kataras/iris"
"github.com/kataras/iris/middleware/logger"
"github.com/merakiVE/CEHDUN/src/controllers"
)
var (
PORT_SERVER = ":8002"
)
func main() {
///Iris
app := iris.New()
//app.Configure(iris.WithConfiguration(iris.YAML("./config_iris.yml")))
APILogger := logger.New(logger.Config{
// Status displays status code
Status: true,
// IP displays request's remote address
IP: true,
// Method displays the http method
Method: true,
// Path displays the request path
Path: true,
})
app.Use(APILogger)
//Enable cors in server
app.WrapRouter(cors.WrapNext(cors.Options{
AllowedOrigins: []string{"*"},
AllowedMethods: []string{"OPTIONS", "GET", "POST", "PUT", "DELETE"},
AllowedHeaders: []string{"*"},
AllowCredentials: true,
Debug: true,
}))
app.Post("/connect", controllers.ConnectDB)
app.Post("/build", controllers.BuildAPI)
app.Run(iris.Addr(PORT_SERVER), iris.WithCharset("UTF-8"))
}