dump the JSON body
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
7110856b18
commit
91e02c329d
|
@ -3,6 +3,7 @@ package main
|
||||||
import "fmt"
|
import "fmt"
|
||||||
import "log"
|
import "log"
|
||||||
import "net/http"
|
import "net/http"
|
||||||
|
import "io/ioutil"
|
||||||
|
|
||||||
import "github.com/davecgh/go-spew/spew"
|
import "github.com/davecgh/go-spew/spew"
|
||||||
|
|
||||||
|
@ -12,6 +13,15 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
||||||
log.Printf("handler: fucking unknown path")
|
log.Printf("handler: fucking unknown path")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
log.Println("listen on :9000")
|
||||||
|
|
||||||
|
http.HandleFunc("/", handler)
|
||||||
|
http.HandleFunc("/email", handler2)
|
||||||
|
|
||||||
|
http.ListenAndServe(":9000", nil)
|
||||||
|
}
|
||||||
|
|
||||||
func handler2(w http.ResponseWriter, r *http.Request) {
|
func handler2(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Access-Control-Allow-Origin", "*")
|
w.Header().Set("Access-Control-Allow-Origin", "*")
|
||||||
w.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE")
|
w.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE")
|
||||||
|
@ -42,13 +52,14 @@ func handler2(w http.ResponseWriter, r *http.Request) {
|
||||||
log.Printf("handler2 DEFAULT Method=", r.Method)
|
log.Printf("handler2 DEFAULT Method=", r.Method)
|
||||||
spew.Dump(r.Method)
|
spew.Dump(r.Method)
|
||||||
}
|
}
|
||||||
}
|
log.Println("Hi there, handler2 r.URL.Path =", r.URL.Path[1:])
|
||||||
|
log.Println("Hi there, handler2 r.URL.Path =", r.URL.Path)
|
||||||
func main() {
|
log.Println("Hi there, handler2 r.URL =", r.URL)
|
||||||
log.Println("listen on :9000")
|
log.Println("Hi there, handler2 r =", r)
|
||||||
|
log.Println("Hi there, handler2 r.Body =", r.Body)
|
||||||
http.HandleFunc("/", handler)
|
|
||||||
http.HandleFunc("/email", handler2)
|
body, err := ioutil.ReadAll(r.Body)
|
||||||
|
j := string(body)
|
||||||
http.ListenAndServe(":9000", nil)
|
log.Println("body =", j)
|
||||||
|
log.Println("err =", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue