-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.go
40 lines (31 loc) · 955 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
36
37
38
39
40
package main
import (
"net/http"
"github.com/pilu/traffic"
)
var router *traffic.Router
func init() {
// Create a Traffic router instance
router = traffic.New()
}
// Set up the paths and handlers then start serving.
func main() {
// Add the home route first
router.Get("/", home)
//router.Get("/account/", authMiddleware(account))
router.Get("/account/", account)
router.Get("/login/", login)
router.Post("/login/", login)
//router.Post("/login/", login)
router.Get("/auth/", trafficWrapper(Auth.NewServeMux()))
router.Post("/auth/", trafficWrapper(Auth.NewServeMux()))
// Publish the generated Page in a way that connects the HTML and CSS
//page.Publish(mux, "/", "/style.css", false)
// Listen for requests at port set by traffic.conf
router.Run()
}
func trafficWrapper(f http.Handler) traffic.HttpHandleFunc {
return func(w traffic.ResponseWriter, r *traffic.Request) {
f.ServeHTTP(w.(http.ResponseWriter), r.Request)
}
}