package main import ( "log" "net/http" "encoding/json" ) type output struct{} func (o output) ServeHTTP(w http.ResponseWriter, r *http.Request) { jsonOutput, err := json.MarshalIndent (r.RemoteAddr, "", " ") if err != nil { w.Write([]byte(err.Error())) } w.Write(jsonOutput) } func main() { log.Fatal(http.ListenAndServe(":8080", output{})) }