-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
50 lines (39 loc) · 1.13 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
package main
import (
"github.com/gouef/diago"
"github.com/gouef/diago/extensions"
"github.com/gouef/router"
extensions2 "github.com/gouef/router/extensions"
//web_bootstrap "github.com/gouef/web-bootstrap"
"github.com/gouef/web-project/app"
"github.com/gouef/web-project/controllers"
"github.com/gouef/web-project/handlers"
)
func boot() *router.Router {
/*b := web_bootstrap.NewBootstrap()
b.Boot()*/
r := router.NewRouter()
n := r.GetNativeRouter()
if !r.IsRelease() {
d := diago.NewDiago()
d.AddExtension(extensions.NewDiagoLatencyExtension())
d.AddExtension(extensions2.NewDiagoRouteExtension(r))
n.Use(diago.DiagoMiddleware(r, d))
}
templateHandler := &handlers.TemplateHandler{Router: r}
// Inicializace šablon
templateHandler.Initialize()
n.SetTrustedProxies([]string{"127.0.0.1"})
n.LoadHTMLGlob("views/templates/**/*.gohtml")
n.Static("/static", "./static")
rl := app.RouterFactory()
r.SetErrorHandler(404, controllers.Error404)
r.SetErrorHandler(500, controllers.Error500)
r.SetDefaultErrorHandler(controllers.Error404)
r.AddRouteList(rl)
return r
}
func main() {
r := boot()
r.Run(":8080")
}