-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathmain.go
35 lines (27 loc) · 911 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
package main
import (
"github.com/kataras/iris/v12"
"github.com/kataras/iris/v12/middleware/logger"
"github.com/kataras/iris/v12/middleware/recover"
_ "github.com/go-sql-driver/mysql"
"github.com/JabinGP/demo-chatroom/config"
"github.com/JabinGP/demo-chatroom/middleware"
"github.com/JabinGP/demo-chatroom/route"
)
func main() {
app := iris.New()
// Set logger level
app.Logger().SetLevel(config.Viper.GetString("server.logger.level"))
// Add recover to recover from any http-relative panics
app.Use(recover.New())
// Add logger to log the requests to the terminal
app.Use(logger.New())
// Globally allow options method to enable CORS
app.AllowMethods(iris.MethodOptions)
// Add global CORS handler
app.Use(middleware.CORS)
// Router
route.Route(app)
// Listen in 8888 port
app.Run(iris.Addr(config.Viper.GetString("server.addr")), iris.WithoutServerError(iris.ErrServerClosed))
}