-
Notifications
You must be signed in to change notification settings - Fork 11
/
main.go
67 lines (50 loc) · 1.66 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package main
import (
"gopub/models"
"gopub/web/routes"
"gopub/websocket"
"github.com/kataras/iris"
"github.com/kataras/iris/middleware/logger"
)
var App = iris.New()
func main() {
customLogger := logger.New(logger.Config{
// Status displays status code
Status: true,
// IP displays request's remote address
IP: true,
// Method displays thea http method
Method: true,
// Path displays the request path
Path: true,
// Query appends the url query to the Path.
Query: true,
// Columns: true,
// if !empty then its contents derives from `ctx.Values().Get("logger_message")
// will be added to the logs.
MessageContextKeys: []string{"logger_message"},
// if !empty then its contents derives from `ctx.GetHeader("User-Agent")
// MessageHeaderKeys: []string{"User-Agent"},
})
App.Favicon("./favicon.ico")
App.Use(customLogger)
// App.Logger().SetLevel("debug")
// Load the template files.
tmpl := iris.HTML("./html/views", ".html").Layout("layouts/layout.html").Reload(true)
App.RegisterView(tmpl)
route := new(routes.Routes)
route.InitRoute(App)
App.StaticWeb("/assets", "./html/assets")
websocket.SetupWebsocket(App)
App.Run(iris.Addr(models.AppConfig.Listen), iris.WithConfiguration(iris.Configuration{
DisableStartupLog: false,
DisableInterruptHandler: false,
DisablePathCorrection: false,
EnablePathEscape: true,
FireMethodNotAllowed: false,
DisableBodyConsumptionOnUnmarshal: false,
DisableAutoFireStatusCode: false,
TimeFormat: "Mon, 02 Jan 2006 15:04:05 GMT",
Charset: "UTF-8",
}))
}