25 lines
421 B
Go
25 lines
421 B
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/json"
|
|
"fmt"
|
|
"io/ioutil"
|
|
"net/http"
|
|
)
|
|
|
|
func main() {
|
|
http.ListenAndServe(":5001", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
b, err := ioutil.ReadAll(r.Body)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
defer r.Body.Close()
|
|
var buf bytes.Buffer
|
|
if err := json.Indent(&buf, b, " >", " "); err != nil {
|
|
panic(err)
|
|
}
|
|
fmt.Println(buf.String())
|
|
}))
|
|
}
|