You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021
  1. package main
  2. import (
  3. "log"
  4. "net/http"
  5. "encoding/json"
  6. )
  7. type output struct{}
  8. func (o output) ServeHTTP(w http.ResponseWriter, r *http.Request) {
  9. jsonOutput, err := json.MarshalIndent (r.RemoteAddr, "", " ")
  10. if err != nil {
  11. w.Write([]byte(err.Error()))
  12. }
  13. w.Write(jsonOutput)
  14. }
  15. func main() {
  16. log.Fatal(http.ListenAndServe(":8080", output{}))
  17. }