I am trying to use rack middleware authentication. I want to exclude certain path from the authentication. Is it possible to exclude some specific path?
This will authenticate all the routes starts with home.
def call(env)
request = Rack::Request.new(env)
if request.path =~ /^\/home/
super
else
@app.call(env)
end
end
I want that the path "home/users/" should be excluded from the authentication. All other path starting from "home/" should be authenticate. Any lead please, thanks.
If you want to exclude only "home/users/" path then you middleware should have following structure,
def call(env)
request = Rack::Request.new(env)
return @app.call(env) if request.path == "home/users/"
# your middleware logic of authentication here.
end
For more information of rack, you can refer this .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.