sinatra / sinatra

Classy web-development dressed in a DSL (official / canonical repo)

Home Page:https://sinatrarb.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Route Middleware

riteshapatel opened this issue · comments

Does Sinatra support middleware at route level? For example, in NodeJS I can do as below.

router.post("/like", validate(generic.FieldValueSchema), catchIt(controller.searchLike))

# validate is simply a generic payload / schema validator

In the event of a wrong payload I want to fail fast and not even reach the route handler.

Or what is the best way to do route level schema validation in Sinatra?

Any thoughts?