package main
import "fmt"
import "net/http"
func home(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "What!")
}
func bar(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Bar!")
}
func main() {
http.HandleFunc("/", home)
http.HandleFunc("/foo", bar)
http.ListenAndServe(":5678", nil)
}
If I visit /foo
, bar
will run.
If I visit /
or /any/other/path
, home
will run.
Any idea why this happens? How can I handle 404's?