H
Hono4mo ago
bombillazo

Return early from middleware

Hello, I want to return a 200 response from a middleware if certain conditions are not met, else run await and cleanup after the await. How can I return early from the middleare function?
2 Replies
bombillazo
bombillazoOP4mo ago
So the error I had was unrelated to the return, returning normally early with the response object works!
Aditya Mathur
Aditya Mathur4mo ago
You also just do return c.text("Works!") inside the middleware, this should be before await next() line. Also if you want to throw an error try using HTTPException
Want results from more Discord servers?
Add your server