Class: Ronflex::Rest
- Inherits:
-
Object
- Object
- Ronflex::Rest
- Defined in:
- lib/ronflex/rest.rb
Instance Method Summary collapse
-
#call(env) ⇒ Array
Rack middleware call method that processes the incoming request.
-
#initialize(app) ⇒ Rest
constructor
Initializes the middleware with the given app.
Constructor Details
#initialize(app) ⇒ Rest
Initializes the middleware with the given app
7 8 9 |
# File 'lib/ronflex/rest.rb', line 7 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Array
Rack middleware call method that processes the incoming request.
It checks if the request should be granted access, and if not, it returns the maintenance page or proceeds with the normal request handling.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ronflex/rest.rb', line 22 def call(env) request = Rack::Request.new(env) model = Ronflex.configuration.provider.call(env) # If the request is always accessible (excluded path), pass the request to the next app return @app.call(env) if always_access?(request) # If the system is enabled and the model is present and authorized, proceed with the request if Ronflex.configuration.enable if model_present?(model) && (model, request) return @app.call(env) else # If conditions are not met, return maintenance page return [503, { "Content-Type" => "text/html" }, [maintenance_page]] end end # Default pass-through for the request @app.call(env) end |