This commit is contained in:
Zheng Kai
2023-03-30 10:07:57 +08:00
parent 1b107ed035
commit 049277f1f6
19 changed files with 889 additions and 20 deletions

28
server/src/core/web.go Normal file
View File

@@ -0,0 +1,28 @@
package core
import (
"net/http"
"project/metrics"
)
// WebHandle ...
func (c *Core) WebHandle(w http.ResponseWriter, r *http.Request) {
p, hash, err := req(w, r)
if err != nil {
metrics.ReqFailCount()
return
}
metrics.ReqBytes(len(p.Body))
pr := c.add(hash, p)
pr.wait()
if pr.err != nil {
err500(w)
return
}
w.Write(pr.rsp)
}