diff options
| author | Jeff Carr <[email protected]> | 2025-09-06 15:36:36 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-09-06 16:04:51 -0500 |
| commit | 0d1f53afee67293e930d9f67bd71442c154d196a (patch) | |
| tree | 6d7d559e27aea94c1b746be9d3e3f4965bebc598 /handlePatches.go | |
| parent | d795dbeb610a8b0aa315e39175f574dd5ee0cc4e (diff) | |
all kindsa crazy. this needs massive cleanup
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) |
