keep working towards common http PB
This commit is contained in:
parent
4e5a34b772
commit
eae2c3be2b
|
@ -9,22 +9,11 @@ import (
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func handlePatches(w http.ResponseWriter, r *http.Request, data []byte) error {
|
func handlePatches(w http.ResponseWriter, pb *forgepb.Patches) error {
|
||||||
pb, err := marshalPatchesPB(r, data)
|
|
||||||
if err != nil {
|
|
||||||
return sendPatchesError(w, pb, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
route := pb.HttpRequest.Route
|
route := pb.HttpRequest.Route
|
||||||
if route == "" {
|
|
||||||
route = cleanURL(r.URL.Path)
|
|
||||||
}
|
|
||||||
if route == "" {
|
|
||||||
route = "route was blank"
|
|
||||||
}
|
|
||||||
log.Info("GOT PATCHES ROUTE", route, "with # patches =", pb.Len())
|
log.Info("GOT PATCHES ROUTE", route, "with # patches =", pb.Len())
|
||||||
if strings.HasPrefix(route, "/patches/old") {
|
if strings.HasPrefix(route, "/patches/old") {
|
||||||
processPatchesOldPB(r, pb)
|
|
||||||
} else if strings.HasPrefix(route, "/patches/new") {
|
} else if strings.HasPrefix(route, "/patches/new") {
|
||||||
log.Info("add new patches")
|
log.Info("add new patches")
|
||||||
} else {
|
} else {
|
||||||
|
@ -45,12 +34,6 @@ func sendPatchesError(w http.ResponseWriter, r *forgepb.Patches, err error) erro
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func processPatchesOldPB(r *http.Request, pb *forgepb.Patches) error {
|
|
||||||
log.Info("check out these patches")
|
|
||||||
pb.PrintTable()
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func marshalPatchesPB(r *http.Request, msg []byte) (*forgepb.Patches, error) {
|
func marshalPatchesPB(r *http.Request, msg []byte) (*forgepb.Patches, error) {
|
||||||
pb := forgepb.NewPatches()
|
pb := forgepb.NewPatches()
|
||||||
|
|
||||||
|
|
14
http.go
14
http.go
|
@ -117,7 +117,14 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(route, "/patches/") {
|
if strings.HasPrefix(route, "/patches/") {
|
||||||
handlePatches(w, r, reqPB.Body)
|
/*
|
||||||
|
pb, err := forgepb.GetPatchesFromHttp(reqPB)
|
||||||
|
if err != nil {
|
||||||
|
log.Info("error converting to patches PB")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
handlePatches(w, pb)
|
||||||
|
*/
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,11 +157,6 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(route, "/patches/") {
|
|
||||||
handlePatches(w, r, reqPB.Body)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if route == "/patchset" {
|
if route == "/patchset" {
|
||||||
if err := savePatchset(w, reqPB.Body); err != nil {
|
if err := savePatchset(w, reqPB.Body); err != nil {
|
||||||
log.Warn("forged /patchset error", err)
|
log.Warn("forged /patchset error", err)
|
||||||
|
|
Loading…
Reference in New Issue