/
server.go
52 lines (40 loc) · 1.31 KB
/
server.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
package main
import (
"github.com/go-martini/martini"
"github.com/martini-contrib/render"
)
func main() {
m := martini.Classic()
StaticOptions := martini.StaticOptions{Prefix: "public"}
m.Use(martini.Static("public", StaticOptions))
m.Use(martini.Static("public", StaticOptions))
m.Use(martini.Static("public", StaticOptions))
m.Use(martini.Static("public", StaticOptions))
m.Use(render.Renderer(render.Options{
Directory: "templates", // Specify what path to load the templates from.
Layout: "layout", // Specify a layout template. Layouts can call {{ yield }} to render the current template.
Extensions: []string{".tmpl"}, // Specify extensions to load for templates.
Charset: "UTF-8", // Sets encoding for json and html content-types. Default is "UTF-8".
}))
m.Get("/", IndexRouter)
m.Get("/about", AboutRoute)
m.Get("/contact", ContactRoute)
m.Get("/signin", SigninRoute)
m.Get("/signup", SignupRoute)
m.Run()
}
func IndexRouter(r render.Render) {
r.HTML(200, "home/index", nil)
}
func AboutRoute(r render.Render) {
r.HTML(200, "home/about", nil)
}
func ContactRoute(r render.Render) {
r.HTML(200, "home/contact", nil)
}
func SigninRoute(r render.Render) {
r.HTML(200, "account/signin", nil)
}
func SignupRoute(r render.Render) {
r.HTML(200, "account/signup", nil)
}