Replies: 1 comment 3 replies
-
just return error and do not use |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
How can i return an error from middleware that contains a json body and halts the chain, terminating the request flow?
I initially tried just returning json with an error http code (typeof errs is
url.Values
):But this wasn't halting the chain and terminating the request flow. So instead I make the call to the context
JSON
func and then return the error like so:Which works, but each time this happens, a warning is written to the console to explain that the response has already been sent.
So my question is: is there a better way of doing this? I've had a look around and haven't managed to find anything.
Beta Was this translation helpful? Give feedback.
All reactions