lmao if you can serve static files
This commit is contained in:
parent
0939b1ebcd
commit
be1e34f0b7
@ -8,8 +8,7 @@ func hello(res http.ResponseWriter, req *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func static(res http.ResponseWriter, req *http.Request) {
|
func static(res http.ResponseWriter, req *http.Request) {
|
||||||
res.Header().Set("Content-Type", "text/plain")
|
http.ServeFile(res, req, "./01-hello.go")
|
||||||
fmt.Fprintln(res, "Static")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func notFound(res http.ResponseWriter, req *http.Request) {
|
func notFound(res http.ResponseWriter, req *http.Request) {
|
||||||
@ -21,7 +20,7 @@ func notFound(res http.ResponseWriter, req *http.Request) {
|
|||||||
func main() {
|
func main() {
|
||||||
r := mux.NewRouter()
|
r := mux.NewRouter()
|
||||||
r.HandleFunc("/", hello)
|
r.HandleFunc("/", hello)
|
||||||
r.HandleFunc("/favicon.ico", static)
|
r.HandleFunc("/01-hello.go", static)
|
||||||
r.HandleFunc("/{path:.*}", notFound)
|
r.HandleFunc("/{path:.*}", notFound)
|
||||||
http.ListenAndServe(":5000", r)
|
http.ListenAndServe(":5000", r)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user