Skip to content

Commit

Permalink
fix/move unmarshal in doRequest block (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
MindHunter86 authored Jul 18, 2024
2 parents 46e4780 + 808b20f commit 3c9810b
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions internal/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,6 @@ func (m *Proxy) ProxyFiberRequest(c *fiber.Ctx) (e error) {
return
}

var ok bool
if ok, e = m.unmarshalApiResponse(c, rsp); e != nil {
rlog(c).Warn().Msg(e.Error())
m.bypassCache(c)
} else if !ok {
m.bypassCache(c)
}

if !m.IsCacheBypass(c) {
return m.cacheAndRespond(c, rsp)
}
Expand Down Expand Up @@ -108,6 +100,15 @@ func (m *Proxy) doRequest(c *fiber.Ctx, req *fasthttp.Request, rsp *fasthttp.Res

if len(body) == 0 {
e = errors.New("proxy server respond with nil body")
return
}

var ok bool
if ok, e = m.unmarshalApiResponse(c, rsp); e != nil {
rlog(c).Warn().Msg(e.Error())
m.bypassCache(c)
} else if !ok {
m.bypassCache(c)
}

return
Expand Down

0 comments on commit 3c9810b

Please sign in to comment.