-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Description
I put this question on SO and am looking for answers - this question may be based off a false assumption:
https://stackoverflow.com/questions/60679922/how-to-break-out-of-martini-middleware
but at the very least I have no idea how martini would know when to keep invoking the middleware chain and when not to? it wouldn't know even if you aleady set the http status code or wrote the response body, you may still want to keep writing in subsequent middleware funcs. someone please explain how to return early out of the chain.
Perhaps this is the best way to do it?
m.Use(func(c martini.Context, w http.ResponseWriter){
if reqIsMalformed() {
http.Error(w, "Bad request because xyz", 422)
return;
}
c.Next() // only invoke remaining middleware if the request is valid?
})Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels