Getting rack error Rack::Lint::LintError: Status must be >=100 seen as integer
-
30-06-2021 - |
Question
I'm trying to build my rack based ruby app, and I'm still new here, I'm using ruby 1.9.2 -p180
in my config.ru file I have:
require "rack"
require "./my_app.rb"
require "./auth.rb"
use Auth
run MyApp.new
Now main problem with Middleware Auth, simply, I want it to not continue MyApp if there were less than 2 params for the request and just print out something ( just for testing ) :
class Auth
def initialize(app)
@app = app
end
def call(env)
request = Rack::Request.new(env)
if request.params.count < 2
["200",{"Content-Type" => "text/plain"}, ["Hello World"]]
puts 'Working .. '
else
@app.call(env)
end
end
end
Now when I run my rack app :
rackup -s thin config.ru
And try to get the results :
curl http://localhost:9292/
I keep getting the following error :
Rack::Lint::LintError: Status must be >=100 seen as integer
/Users/Apple/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.4.1/lib/rack/lint.rb:19:in `assert'
/Users/Apple/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.4.1/lib/rack/lint.rb:425:in `check_status'
Of course if I run it with production mode I will not get this error.
Any help would be appreciated here .
Solution
Try using an integer for the status:
[200,{"Content-Type" => "text/plain"}, ["Hello World"]]
Instead of:
["200",{"Content-Type" => "text/plain"}, ["Hello World"]]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow