-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.go
45 lines (36 loc) · 1.07 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
package main
import (
"html/template"
"io"
"github.com/KerwinKoo/go-wifidog-authserver/wdmethods"
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
)
// Template init
type Template struct {
templates *template.Template
}
// Render base render
func (t *Template) Render(w io.Writer, name string, data interface{}, c echo.Context) error {
return t.templates.ExecuteTemplate(w, name, data)
}
func main() {
t := &Template{
templates: template.Must(template.ParseGlob("template/*.html")),
}
e := echo.New()
e.Renderer = t
e.Static("/static", "static")
e.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
Format: "time=${time_rfc3339}, method=${method}, uri=${uri}, status=${status}\n",
}))
loginCtx := wdmethods.NewLoginCtx()
wdGroup := e.Group("/wifidog")
// wdGroup.Use(middleware.AddTrailingSlash())
wdGroup.GET("/ping/", loginCtx.Ping)
wdGroup.GET("/login/", loginCtx.Login)
wdGroup.GET("/logincheck", loginCtx.LoginCheck)
wdGroup.GET("/auth/", loginCtx.Auth)
wdGroup.GET("/portal/", loginCtx.Portal)
e.Logger.Fatal(e.Start(":8082"))
}