package main import ( "fmt" "net/http" ) type Engine struct{} func (engine *Engine) ServeHTTP(w http.ResponseWriter, r *http.Request) { switch r.URL.Path { case "/": fmt.Fprintf(w, "URL.Path = %q", r.URL.Path) case "/hello": for k, v := range r.Header { fmt.Fprintf(w, "Header[%q] = %q", k, v) } default: fmt.Fprintf(w, "404 NOT FOUND: %s", r.URL) } } func main() { engine := new(Engine) http.ListenAndServe(":8000", engine) }