mirror of
https://github.com/zhengkai/orca.git
synced 2026-02-17 15:22:29 +08:00
up
This commit is contained in:
@@ -8,12 +8,38 @@ import (
|
||||
"project/zj"
|
||||
)
|
||||
|
||||
func (c *Core) getAB(p *pb.Req, r *http.Request) (ab []byte, cached bool, err error) {
|
||||
ab, ok := tryCache(p)
|
||||
if ok {
|
||||
cached = true
|
||||
return
|
||||
}
|
||||
|
||||
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()
|
||||
|
||||
ab = pr.rsp
|
||||
err = pr.err
|
||||
return
|
||||
}
|
||||
|
||||
func req(w http.ResponseWriter, r *http.Request) (p *pb.Req, err error) {
|
||||
|
||||
path := r.URL.Path
|
||||
method := r.Method
|
||||
|
||||
zj.J(method, path)
|
||||
if path == `/favicon.ico` {
|
||||
err = errSkip
|
||||
return
|
||||
}
|
||||
|
||||
ab, err := io.ReadAll(http.MaxBytesReader(w, r.Body, 1024*1024))
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user