package main import ( "fmt" "net/http" ) type String string func (s String) ServeHTTP(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, s) } type Struct struct { Greeting string Who string Punct string } func (s Struct) ServeHTTP(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "%v %v%v", s.Greeting, s.Who, s.Punct) } func main() { http.Handle("/string/", String("I am a freaking zealot.")) http.Handle("/struct/", Struct{"hello", "world", "!"}) http.ListenAndServe("localhost:4000", nil) }