Selaa lähdekoodia

first commit

tags/v1.0
Ramiro de Zavalia 5 vuotta sitten
vanhempi
commit
f71460b5b2
1 muutettua tiedostoa jossa 21 lisäystä ja 0 poistoa
  1. 21
    0
      main.go

+ 21
- 0
main.go Näytä tiedosto

@@ -0,0 +1,21 @@
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{}))
}

Loading…
Peruuta
Tallenna