more standardation
This commit is contained in:
parent
34d9943e73
commit
c1de4f1f5a
34
http.go
34
http.go
|
@ -50,8 +50,8 @@ func whoSent(r *http.Request) string {
|
||||||
|
|
||||||
func logReqPB(pb *httppb.HttpRequest) {
|
func logReqPB(pb *httppb.HttpRequest) {
|
||||||
log.Info("LOG: httppb.HttpRequest START:")
|
log.Info("LOG: httppb.HttpRequest START:")
|
||||||
for i, line := range strings.Join(pb.Log, "\n") {
|
for i, line := range pb.Log {
|
||||||
log.Infof("\t%d %s\n", i, line)
|
log.Infof("\t%d, URL:%s LINE: %s\n", int(i), pb.URL, line)
|
||||||
}
|
}
|
||||||
log.Info("LOG: httppb.HttpRequest END")
|
log.Info("LOG: httppb.HttpRequest END")
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
reqPB, err := httppb.ReqToPB(r)
|
reqPB, err := httppb.ReqToPB(r)
|
||||||
reqPB.Log = append(reqPB.Log, fmt.Sprintf("START: Got %d bytes from the client", len(reqPB.ClientData)))
|
reqPB.Log = append(reqPB.Log, fmt.Sprintf("START: Got %d bytes from the client", len(reqPB.ClientData)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Info("something crazy err", err)
|
reqPB.Log = append(reqPB.Log, fmt.Sprintf("httppb err %v", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
who := whoSent(r)
|
who := whoSent(r)
|
||||||
|
@ -76,13 +76,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// used for uptime monitor checking
|
reqPB.Log = append(reqPB.Log, log.Sprintf("forged REQUEST URL =", requrl, "from =", who))
|
||||||
if route == "/uptime" {
|
|
||||||
writeFile(w, "uptime.html")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Warn("forged REQUEST URL =", requrl, "from =", who)
|
|
||||||
|
|
||||||
if strings.HasPrefix(route, "/repos/") {
|
if strings.HasPrefix(route, "/repos/") {
|
||||||
pb, err := makeReposPB(reqPB)
|
pb, err := makeReposPB(reqPB)
|
||||||
|
@ -93,16 +87,17 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
switch route {
|
switch route {
|
||||||
case "/repos/check":
|
case "/repos/check":
|
||||||
result = addRequest(pb, reqPB)
|
result = addRequest(pb, reqPB)
|
||||||
log.Infof("repos check result.Len()=%d pb.Len()=%d\n", result.Len(), pb.Len())
|
reqPB.Log = append(reqPB.Log, log.Sprintf("repos check result.Len()=%d pb.Len()=%d\n", result.Len(), pb.Len()))
|
||||||
case "/repos/pull":
|
case "/repos/pull":
|
||||||
result = pullRequest(pb, reqPB)
|
result = pullRequest(pb, reqPB)
|
||||||
case "/repos/add":
|
case "/repos/add":
|
||||||
result = addRequest(pb, reqPB)
|
result = addRequest(pb, reqPB)
|
||||||
default:
|
default:
|
||||||
|
reqPB.Log = append(reqPB.Log, log.Sprintf("repos check result.Len()=%d pb.Len()=%d\n", result.Len(), pb.Len()))
|
||||||
log.Info("repos", route, "unknown")
|
log.Info("repos", route, "unknown")
|
||||||
}
|
}
|
||||||
if err := result.SendReply(w, reqPB); err != nil {
|
if err := result.SendReply(w, reqPB); err != nil {
|
||||||
log.Info("Oh well, Send to client failed. err =", err)
|
reqPB.Log = append(reqPB.Log, log.Sprintf("Oh well, Send to client failed. err=%v", err))
|
||||||
}
|
}
|
||||||
// todo: logReq(reqPB)
|
// todo: logReq(reqPB)
|
||||||
logReqPB(reqPB)
|
logReqPB(reqPB)
|
||||||
|
@ -118,12 +113,11 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
switch route {
|
switch route {
|
||||||
case "/patches/new":
|
case "/patches/new":
|
||||||
result = addNewPatches(pb, reqPB)
|
result = addNewPatches(pb, reqPB)
|
||||||
log.Infof("addNewPatches() pb.Len()=%d result.Len()=%d\n", pb.Len(), result.Len())
|
reqPB.Log = append(reqPB.Log, log.Sprintf("addNewPatches() pb.Len()=%d result.Len()=%d\n", pb.Len(), result.Len()))
|
||||||
case "/patches/applied":
|
case "/patches/applied":
|
||||||
log.Info("not really anything needs to be done on applied patches?")
|
reqPB.Log = append(reqPB.Log, log.Sprintf("not really anything needs to be done on applied patches?"))
|
||||||
// result = handleAppliedPatches(pb, reqPB)
|
|
||||||
case "/patches/merged":
|
case "/patches/merged":
|
||||||
log.Info("a maintainer has merged these patches")
|
reqPB.Log = append(reqPB.Log, log.Sprintf("a maintainer has merged these patches"))
|
||||||
result = handleMergedPatches(pb, reqPB)
|
result = handleMergedPatches(pb, reqPB)
|
||||||
// result = handleAppliedPatches(pb, reqPB)
|
// result = handleAppliedPatches(pb, reqPB)
|
||||||
case "/patches/get":
|
case "/patches/get":
|
||||||
|
@ -132,7 +126,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
result = addNewPatches(pb, reqPB)
|
result = addNewPatches(pb, reqPB)
|
||||||
}
|
}
|
||||||
if err := result.SendReply(w, reqPB); err != nil {
|
if err := result.SendReply(w, reqPB); err != nil {
|
||||||
log.Info("Oh well, Send to client failed. err =", err)
|
reqPB.Log = append(reqPB.Log, log.Sprintf("Oh well, Send to client failed. err=%v", err))
|
||||||
}
|
}
|
||||||
me.forge.SavePatchsets()
|
me.forge.SavePatchsets()
|
||||||
// todo: logReq(reqPB)
|
// todo: logReq(reqPB)
|
||||||
|
@ -163,6 +157,12 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
logReqPB(reqPB)
|
logReqPB(reqPB)
|
||||||
|
|
||||||
|
// used for uptime monitor checking
|
||||||
|
if route == "/uptime" {
|
||||||
|
writeFile(w, "uptime.html")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if route == "/lookup" {
|
if route == "/lookup" {
|
||||||
log.Info("doing lookup len(reqPB.Body) =", len(reqPB.Body))
|
log.Info("doing lookup len(reqPB.Body) =", len(reqPB.Body))
|
||||||
|
|
Loading…
Reference in New Issue