OLD | NEW |
1 package frontend | 1 package frontend |
2 | 2 |
3 import ( | 3 import ( |
4 "html/template" | 4 "html/template" |
5 "net/http" | 5 "net/http" |
6 "time" | 6 "time" |
7 | 7 |
8 "google.golang.org/appengine" | 8 "google.golang.org/appengine" |
9 | 9 |
10 "github.com/luci/luci-go/appengine/gaemiddleware" | 10 "github.com/luci/luci-go/appengine/gaemiddleware" |
11 "github.com/luci/luci-go/server/router" | 11 "github.com/luci/luci-go/server/router" |
12 "github.com/luci/luci-go/server/templates" | 12 "github.com/luci/luci-go/server/templates" |
13 ) | 13 ) |
14 | 14 |
15 func init() { | 15 func init() { |
16 r := router.New() | 16 r := router.New() |
17 baseMW := base() | 17 baseMW := base() |
18 | 18 |
19 r.GET("/testfile", baseMW, GetHandler) | 19 r.GET("/testfile", baseMW, GetHandler) |
20 r.GET("/testfile/", baseMW, GetHandler) | 20 r.GET("/testfile/", baseMW, GetHandler) |
21 | 21 |
| 22 r.GET("/revision_range", baseMW, revisionHandler) |
| 23 |
22 http.DefaultServeMux.Handle("/", r) | 24 http.DefaultServeMux.Handle("/", r) |
23 } | 25 } |
24 | 26 |
25 // base returns the root middleware chain. | 27 // base returns the root middleware chain. |
26 func base() router.MiddlewareChain { | 28 func base() router.MiddlewareChain { |
27 templateBundle := &templates.Bundle{ | 29 templateBundle := &templates.Bundle{ |
28 Loader: templates.FileSystemLoader("templates"), | 30 Loader: templates.FileSystemLoader("templates"), |
29 DebugMode: appengine.IsDevAppServer(), | 31 DebugMode: appengine.IsDevAppServer(), |
30 FuncMap: template.FuncMap{ | 32 FuncMap: template.FuncMap{ |
31 "timeParams": func(t time.Time) string { | 33 "timeParams": func(t time.Time) string { |
32 return t.Format(paramsTimeFormat) | 34 return t.Format(paramsTimeFormat) |
33 }, | 35 }, |
34 "timeJS": func(t time.Time) int64 { | 36 "timeJS": func(t time.Time) int64 { |
35 return t.Unix() * 1000 | 37 return t.Unix() * 1000 |
36 }, | 38 }, |
37 }, | 39 }, |
38 } | 40 } |
39 | 41 |
40 return gaemiddleware.BaseProd().Extend( | 42 return gaemiddleware.BaseProd().Extend( |
41 templates.WithTemplates(templateBundle), | 43 templates.WithTemplates(templateBundle), |
42 ) | 44 ) |
43 } | 45 } |
OLD | NEW |