kemalcr / kemal

Fast, Effective, Simple Web Framework

Home Page:https://kemalcr.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[feature] allow middleware to transform a response

opened this issue · comments

description

i think kemal should allow middleware to transform responses from routes in addition to transforming requests. it would add a fair bit of power to be able to throw a specific exception in a route and have a middleware catch that exception and return a certain error page

usecases:

  • validate in the route, throw a ValidationError, which the middleware catches and responds with an HTTP 400
  • transform the response body with additional content or processing
  • move certain common processing from routes to middleware