Browse Source

saving prev

bmallred 9 years ago
parent
commit
a6bc2137d0
3 changed files with 6 additions and 2 deletions
  1. 3 0
      handlers/default.go
  2. 1 1
      html/loop.html
  3. 2 1
      main.go

+ 3 - 0
handlers/default.go

2
2
3
import (
3
import (
4
	"html/template"
4
	"html/template"
5
	"log"
5
	"net/http"
6
	"net/http"
6
)
7
)
7
8
13
)
14
)
14
15
15
func DefaultHandler(w http.ResponseWriter, r *http.Request) {
16
func DefaultHandler(w http.ResponseWriter, r *http.Request) {
17
	log.Println("Serving template for the default handler")
16
	if err := templateLoop.Execute(w, nil); err != nil {
18
	if err := templateLoop.Execute(w, nil); err != nil {
19
		log.Println(err)
17
		http.Error(w, err.Error(), http.StatusInternalServerError)
20
		http.Error(w, err.Error(), http.StatusInternalServerError)
18
	}
21
	}
19
}
22
}

+ 1 - 1
html/loop.html

24
</head>
24
</head>
25
<body>
25
<body>
26
    {{ template "content" . }}
26
    {{ template "content" . }}
27
    {{ templates "scripts" . }}
27
    {{ template "scripts" . }}
28
</body>
28
</body>
29
</html>
29
</html>

+ 2 - 1
main.go

14
)
14
)
15
15
16
func main() {
16
func main() {
17
	log.Print("Configuring environment...")
17
	log.Print("Configuring environment")
18
	time.Local = time.UTC
18
	time.Local = time.UTC
19
	ConfigureEnvironment()
19
	ConfigureEnvironment()
20
20
30
	blog := r.PathPrefix("/{username}/blog").Subrouter()
30
	blog := r.PathPrefix("/{username}/blog").Subrouter()
31
	blog.Methods("GET").HandlerFunc(handlers.BlogHandler)
31
	blog.Methods("GET").HandlerFunc(handlers.BlogHandler)
32
32
33
	log.Print("Serving content on ", address())
33
	log.Fatal(http.ListenAndServe(address(), nil))
34
	log.Fatal(http.ListenAndServe(address(), nil))
34
}
35
}