diff options
Diffstat (limited to 'handlePatches.go')
| -rw-r--r-- | handlePatches.go | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/handlePatches.go b/handlePatches.go index c9d7d38..3a0317c 100644 --- a/handlePatches.go +++ b/handlePatches.go @@ -1,7 +1,6 @@ package main import ( - "io/ioutil" "net/http" "strings" @@ -9,8 +8,8 @@ import ( "go.wit.com/log" ) -func handlePatches(w http.ResponseWriter, r *http.Request) error { - pb, err := marshalPatchesPB(r) +func handlePatches(w http.ResponseWriter, r *http.Request, data []byte) error { + pb, err := marshalPatchesPB(r, data) if err != nil { return sendPatchesError(w, pb, err) } @@ -22,9 +21,10 @@ func handlePatches(w http.ResponseWriter, r *http.Request) error { if route == "" { route = "route was blank" } + log.Info("GOT PATCHES ROUTE", route, "with # patches =", pb.Len()) if strings.HasPrefix(route, "/patches/old") { - processPatchesPB(r, pb) - } else if strings.HasPrefix(route, "/patches/old") { + processPatchesOldPB(r, pb) + } else if strings.HasPrefix(route, "/patches/new") { log.Info("add new patches") } else { log.Info("unknown route", route) @@ -38,18 +38,14 @@ func sendPatchesError(w http.ResponseWriter, r *forgepb.Patches, err error) erro return nil } -func processPatchesPB(r *http.Request, pb *forgepb.Patches) error { - log.Info("send error back to user") +func processPatchesOldPB(r *http.Request, pb *forgepb.Patches) error { + log.Info("check out these patches") + pb.PrintTable() return nil } -func marshalPatchesPB(r *http.Request) (*forgepb.Patches, error) { +func marshalPatchesPB(r *http.Request, msg []byte) (*forgepb.Patches, error) { pb := forgepb.NewPatches() - msg, err := ioutil.ReadAll(r.Body) // Read the body as []byte - defer r.Body.Close() - if err != nil { - return pb, err - } if err := pb.Unmarshal(msg); err != nil { log.Info("proto.Unmarshal() failed on wire message len", len(msg), err) |
