why lock udBeforeRequestLock and udBeforeRequestLock in execute
valiner opened this issue · comments
valiner commented
func (c *Client) execute(req *Request) (*Response, error) {
// Lock the user-defined pre-request hooks.
c.udBeforeRequestLock.RLock()
defer c.udBeforeRequestLock.RUnlock()
// Lock the post-request hooks.
c.afterResponseLock.RLock()
defer c.afterResponseLock.RUnlock()
This looks very inefficient.
valiner commented
func (c *Client) OnAfterResponse(m ResponseMiddleware) *Client {
c.afterResponseLock.Lock()
defer c.afterResponseLock.Unlock()
c.afterResponse = append(c.afterResponse, m)
return c
}
OnAfterResponse is generally not used in http execute.
Jeevanandam M. commented
Jeevanandam M. commented
@valiner Also if you have a suggestion to improve, please mention it.