I am getting an error:
invalid memory address or nil pointer dereference
my code looks like:
func (ctr *Controller) Login(c *common.CPContext, req *http.Request, res http.ResponseWriter) (int, interface{}) {
defer func() {
var code = req.Response.StatusCode; // error is here!!
log.Error(code)
if code < 400 {
user.LoginAttempts = 0
} else {
user.LoginAttempts = user.LoginAttempts + 1
}
_, err := user.Update(ctx, db, boil.Infer())
if err != nil {
log.Warningf("could not save/update user model: %v", err)
}
}()
// ...
}
how do I handle the pointer situation here? I just want to get the http.Response and the http.Response.StatusCode specifically here…