Merge pull request #148 from matrix-org/daniel/leadingspacesucks

speculator: Send Content-Type: text/html header
pull/977/head
Daniel Wagner-Hall 9 years ago
commit cfdcf9e5a3

@ -384,16 +384,23 @@ func main() {
log.Fatal(err) log.Fatal(err)
} }
s := server{masterCloneDir} s := server{masterCloneDir}
http.HandleFunc("/spec/", s.serveSpec) http.HandleFunc("/spec/", forceHTML(s.serveSpec))
http.HandleFunc("/diff/rst/", s.serveRSTDiff) http.HandleFunc("/diff/rst/", forceHTML(s.serveRSTDiff))
http.HandleFunc("/diff/html/", s.serveHTMLDiff) http.HandleFunc("/diff/html/", forceHTML(s.serveHTMLDiff))
http.HandleFunc("/healthz", serveText("ok")) http.HandleFunc("/healthz", serveText("ok"))
http.HandleFunc("/", listPulls) http.HandleFunc("/", forceHTML(listPulls))
fmt.Printf("Listening on port %d\n", *port) fmt.Printf("Listening on port %d\n", *port)
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *port), nil)) log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *port), nil))
} }
func forceHTML(h func(w http.ResponseWriter, req *http.Request)) func(w http.ResponseWriter, req *http.Request) {
return func(w http.ResponseWriter, req *http.Request) {
w.Header().Set("Content-Type", "text/html")
h(w, req)
}
}
func serveText(s string) func(http.ResponseWriter, *http.Request) { func serveText(s string) func(http.ResponseWriter, *http.Request) {
return func(w http.ResponseWriter, req *http.Request) { return func(w http.ResponseWriter, req *http.Request) {
io.WriteString(w, s) io.WriteString(w, s)

Loading…
Cancel
Save