Class: Maromi
- Inherits:
-
Object
- Object
- Maromi
- Defined in:
- lib/maromi.rb,
lib/maromi/models.rb,
lib/maromi/helpers.rb,
lib/maromi/proxies.rb,
lib/maromi/version.rb,
lib/maromi/helpers/token.rb,
lib/maromi/models/request.rb,
lib/maromi/helpers/sinatra.rb,
lib/maromi/models/consumer.rb,
lib/maromi/proxies/consumer.rb,
lib/maromi/helpers/lazy_object.rb,
lib/maromi/models/authorization.rb,
lib/maromi/helpers/parameter_list.rb,
lib/maromi/proxies/consumer_request.rb,
lib/maromi/proxies/consumer_authorization.rb,
lib/maromi/helpers/smart_authorizer_marshal.rb
Overview
The Maromi Rack Middleware
Defined Under Namespace
Modules: Helpers, Models, Proxies Classes: Authorization, Consumer, Invalid, Request, Unauthorized
Constant Summary collapse
- REQUIRED_OAUTH_PARAMETERS =
%w( oauth_signature_method oauth_timestamp oauth_nonce oauth_consumer_key oauth_signature )
- VERSION =
"0.0.2"
Instance Method Summary collapse
-
#call(env) ⇒ Array
Performs the request through maromi.
-
#initialize(app, connection_path = nil) ⇒ Maromi
constructor
In most cases, you should not call this method directly, but call Rack’s use method.
Constructor Details
#initialize(app, connection_path = nil) ⇒ Maromi
In most cases, you should not call this method directly, but call Rack’s use method
34 35 36 37 38 39 40 |
# File 'lib/maromi.rb', line 34 def initialize(app, connection_path = nil) @app = app auto_attach_helpers_to app connect_to_datamapper! connection_path unless DataMapper::Repository.adapters[:default] DataMapper.auto_upgrade! end |
Instance Method Details
#call(env) ⇒ Array
Performs the request through maromi
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/maromi.rb', line 46 def call(env) setup env if is_terminal_request? respond_with terminal_response else add_headers with_lazy_authentication { respond_with @app.call(@env) } perform_required_redirects end rescue Unauthorized => e respond_with [ 401, {'Content-Type' => 'text/html'}, ['<h1>Unauthorized.</h1>' + e.] ] rescue Invalid => e respond_with [ 400, {'Content-Type' => 'text/html'}, ['<h1>Invalid</h1>' + e.] ] ensure return @response end |