Class: HelixWebServices::Master
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- HelixWebServices::Master
- Defined in:
- lib/helix_web_services.rb
Overview
A master Sinatra instance that basically sets up routing to each of the sub-applications, and connects the authorization mechanism.
In the future, we may have status and health check functionality available here.
We mount each application under a “versioned” subpath. This allows us to keep an old and new version of a sub-application in the system at the same time, ideally to allow for migration to breaking changes.
Class Method Summary (collapse)
- + (Object) register_app(app)
-
+ (Object) use_after_settings(middleware, *args, &block)
This is special method to inject custom middleware after you know the per-request settings have been initialized.
Class Method Details
+ (Object) register_app(app)
114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/helix_web_services.rb', line 114 def register_app(app) use app app.register HelixWebServices::ErrorHandling app.before do content_type 'application/json' headers['X-Helix-Web-Services-Version'] = HelixWebServices::PRODUCT_ID end app.helpers HWSHelpers app.not_found do status 404 '' end end |
+ (Object) use_after_settings(middleware, *args, &block)
This is special method to inject custom middleware after you know the per-request settings have been initialized.
144 145 146 147 148 |
# File 'lib/helix_web_services.rb', line 144 def self.use_after_settings(middleware, *args, &block) @prototype = nil settings_index = @middleware.index { |m| m.first == HWSSettings } @middleware.insert settings_index + 1, [middleware, args, block] end |