final small version
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
91e02c329d
commit
95b4b77b27
|
@ -5,7 +5,7 @@ import "log"
|
|||
import "net/http"
|
||||
import "io/ioutil"
|
||||
|
||||
import "github.com/davecgh/go-spew/spew"
|
||||
// import "github.com/davecgh/go-spew/spew"
|
||||
|
||||
func handler(w http.ResponseWriter, r *http.Request) {
|
||||
// spew.Dump(r)
|
||||
|
@ -27,37 +27,9 @@ func handler2(w http.ResponseWriter, r *http.Request) {
|
|||
w.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE")
|
||||
w.Header().Set("Access-Control-Allow-Headers", "Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization")
|
||||
|
||||
spew.Dump(r)
|
||||
// spew.Dump(r)
|
||||
fmt.Fprintf(w, "Hi there, handler2 %s!", r.URL.Path[1:])
|
||||
|
||||
log.Printf("handler: method switch statement")
|
||||
switch r.Method {
|
||||
case http.MethodGet:
|
||||
// Serve the resource.
|
||||
log.Printf("handler2 GET")
|
||||
case http.MethodPost:
|
||||
// Create a new record.
|
||||
log.Printf("handler2 POST")
|
||||
case http.MethodPut:
|
||||
// Update an existing record.
|
||||
log.Printf("handler2 PUT")
|
||||
case http.MethodDelete:
|
||||
// Remove the record.
|
||||
log.Printf("handler2 DELETE")
|
||||
case http.MethodOptions:
|
||||
// Remove the record.
|
||||
log.Printf("handler2 OPTIONS")
|
||||
default:
|
||||
// Give an error message.
|
||||
log.Printf("handler2 DEFAULT Method=", 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)
|
||||
log.Println("Hi there, handler2 r.URL =", r.URL)
|
||||
log.Println("Hi there, handler2 r =", r)
|
||||
log.Println("Hi there, handler2 r.Body =", r.Body)
|
||||
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
j := string(body)
|
||||
log.Println("body =", j)
|
||||
|
|
Loading…
Reference in New Issue