|
|
@@ -23,11 +23,13 @@ var ( |
|
|
|
var paths = map[string]string { |
|
|
|
"home": "home.tpl", |
|
|
|
"terms": "terms.tpl", |
|
|
|
"app": "app.tpl", |
|
|
|
} |
|
|
|
|
|
|
|
var pages = map[string]Page { |
|
|
|
"home": cache("home", "Home"), |
|
|
|
"terms": cache("terms", "Terms and Conditions"), |
|
|
|
"app": cache("app", "App"), |
|
|
|
} |
|
|
|
|
|
|
|
func cache(name string, title string) Page { |
|
|
@@ -72,6 +74,10 @@ func route(w http.ResponseWriter, r *http.Request) { |
|
|
|
page = pages[ "home" ] |
|
|
|
case match(p, "/terms", &args): |
|
|
|
page = pages[ "terms" ] |
|
|
|
case match(p, "/app", &args): |
|
|
|
page = pages[ "app" ] |
|
|
|
case match(p, "/assets", &args): |
|
|
|
page = pages[ "app" ] |
|
|
|
default: |
|
|
|
http.NotFound(w, r) |
|
|
|
return |
|
|
@@ -81,7 +87,9 @@ func route(w http.ResponseWriter, r *http.Request) { |
|
|
|
} |
|
|
|
|
|
|
|
func main() { |
|
|
|
files := http.FileServer(http.Dir("")) |
|
|
|
|
|
|
|
http.Handle("/assets/", files) |
|
|
|
http.HandleFunc("/", route) |
|
|
|
log.Fatal(http.ListenAndServe(address, nil)) |
|
|
|
} |
|
|
|
|