This commit is contained in:
Zheng Kai
2023-03-30 16:41:44 +08:00
parent 049277f1f6
commit af429a393a
13 changed files with 155 additions and 29 deletions

View File

@@ -3,19 +3,27 @@ package core
import (
"net/http"
"project/metrics"
"project/util"
)
// WebHandle ...
func (c *Core) WebHandle(w http.ResponseWriter, r *http.Request) {
p, hash, err := req(w, r)
p, err := req(w, r)
if err != nil {
metrics.ReqFailCount()
return
}
metrics.ReqBytes(len(p.Body))
pr := c.add(hash, p)
pr := c.add(p, r)
go func() {
reqFile := util.CacheName(p.Hash()) + `-req.json`
if !util.FileExists(reqFile) {
util.WriteFile(reqFile, p.Body)
}
}()
pr.wait()