Skip to content

Instantly share code, notes, and snippets.

@JenHsuan
Last active January 6, 2019 05:10
Show Gist options
  • Save JenHsuan/6307242dc627b89eb7fdd30cc43c5086 to your computer and use it in GitHub Desktop.
Save JenHsuan/6307242dc627b89eb7fdd30cc43c5086 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"net/http"
)
type car int
func (m car) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
fmt.Fprintln(w, "<h1>car</h1>")
fmt.Fprintln(w, r.Method)
fmt.Fprintln(w, r.URL)
fmt.Fprintln(w, r.Form)
fmt.Fprintln(w, r.Header)
fmt.Fprintln(w, r.Host)
fmt.Fprintln(w, r.ContentLength)
}
func main() {
var c car
http.ListenAndServe(":8080", c)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment