From be1e34f0b7850b2a6b3a15a8fc319f6304ce5b35 Mon Sep 17 00:00:00 2001 From: Mark McGranaghan Date: Thu, 20 Sep 2012 13:25:54 -0700 Subject: [PATCH] lmao if you can serve static files --- src/xx-http-server-static-select.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/xx-http-server-static-select.go b/src/xx-http-server-static-select.go index 35d5e44..c1219b1 100644 --- a/src/xx-http-server-static-select.go +++ b/src/xx-http-server-static-select.go @@ -8,8 +8,7 @@ func hello(res http.ResponseWriter, req *http.Request) { } func static(res http.ResponseWriter, req *http.Request) { - res.Header().Set("Content-Type", "text/plain") - fmt.Fprintln(res, "Static") + http.ServeFile(res, req, "./01-hello.go") } func notFound(res http.ResponseWriter, req *http.Request) { @@ -21,7 +20,7 @@ func notFound(res http.ResponseWriter, req *http.Request) { func main() { r := mux.NewRouter() r.HandleFunc("/", hello) - r.HandleFunc("/favicon.ico", static) + r.HandleFunc("/01-hello.go", static) r.HandleFunc("/{path:.*}", notFound) http.ListenAndServe(":5000", r) }