Skip to content

Commit

Permalink
Add Rack::BadRequest::Middleware.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Jan 12, 2023
1 parent 5878656 commit 8010723
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/rack/bad_request.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
module Rack
module BadRequest
class Middleware
def initialize(app)
@app = app
end

def call(env)
@app.call(env)
rescue BadRequest => error
[400, {}, ["Bad Request: #{error.message}"]]
end
end
end
end

0 comments on commit 8010723

Please sign in to comment.