How to deal with recovery middleware?
Rick1125 opened this issue · comments
Rick Lee commented
You said Alice make no garentees with middleware's behaviors,
it will stop the chain when panic,
so how can I make recovery as a middleware?
Justinas Stankevičius commented
The net/http
server will recover from panics automatically (see the relevant code).
However, if you'd like to roll out your own recovery middleware, it should kick in as early as possible in the request lifecycle. Ideally, it should be the first in the chain.
alice.New(recoveryMiddleware, ...).Then(handler)