Class: Rhoconnect::Server
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- Rhoconnect::Server
- Extended by:
- Condition::AddParameter, Condition::AdminRequired, Condition::ClientRequired, Condition::LoginRequired, Condition::SourceRequired, Condition::Verbs, Condition::VerifySuccess
- Includes:
- Rhoconnect, Handler::Authenticate::ExecuteMethods, Handler::Changes::ExecuteMethods, Handler::PluginCallbacks::ExecuteMethods, Handler::Query::ExecuteMethods, Handler::Search::ExecuteMethods
- Defined in:
- lib/rhoconnect/server.rb
Direct Known Subclasses
Constant Summary
Constants included from Rhoconnect
API_TOKEN_HEADER, API_VERSION, APP_NAME, CLIENT_ID_HEADER, CURRENT_APP, CURRENT_CLIENT, CURRENT_REQUEST, CURRENT_SOURCE, CURRENT_USER, PAGE_OBJECT_COUNT_HEADER, PAGE_TOKEN_HEADER, QUERY_RES, SYNC_VERSION, SourceAdapter, SourceAdapterException, SourceAdapterLoginException, SourceAdapterLogoffException, SourceAdapterObjectConflictErrorException, SourceAdapterServerErrorException, SourceAdapterServerTimeoutException, UNKNOWN_CLIENT, UNKNOWN_SOURCE, VERSION
Class Method Summary collapse
- ._use_async_framework ⇒ Object
- .api4(resource, route_url, verb = :post, options = {}, &block) ⇒ Object
- .new ⇒ Object
- .paths(verb = nil) ⇒ Object
- .set_default(setting, value) ⇒ Object
Methods included from Condition::AdminRequired
extended, include_admin_required_condition
Methods included from Condition::LoginRequired
extended, include_login_required_condition
Methods included from Condition::SourceRequired
extended, include_source_required_condition
Methods included from Condition::ClientRequired
extended, include_client_required_condition
Methods included from Condition::Verbs
extended, include_verbs_condition
Methods included from Condition::VerifySuccess
extended, include_verify_success_condition
Methods included from Condition::AddParameter
extended, include_add_parameter_condition
Methods included from Handler::Authenticate::ExecuteMethods
#execute_admin_authenticate_handler, #execute_authenticate_handler, #execute_rps_authenticate_handler
Methods included from Handler::PluginCallbacks::ExecuteMethods
#do_fast_delete, #do_fast_insert, #do_fast_update, #execute_push_objects_handler
Methods included from Handler::Search::ExecuteMethods
Methods included from Handler::Changes::ExecuteMethods
#_extract_cud_params, #_run_cud_handler, #execute_create_handler, #execute_cud_handler, #execute_delete_handler, #execute_update_handler
Methods included from Handler::Query::ExecuteMethods
Methods included from Rhoconnect
#add_to_url_map, #app, #bootstrap, #camelize, #check_and_add, #check_default_secret!, #check_for_schema_field!, #create_admin_user, #create_predefined_source, #environment, #expire_bulk_data, #get_config, #get_random_identifier, #get_token, #getelement, #lap_timer, #log, #register_predefined_source, #remove_from_url_map, #setelement, settings, shutdown, #source_config, #start_app, #start_nodejs_channels, #start_timer, #timenow, #under_score, #unzip_file, #url_map, #which
Class Method Details
._use_async_framework ⇒ Object
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/rhoconnect/server.rb', line 149 def self._use_async_framework return false if settings.respond_to?(:use_async_model) and settings.use_async_model == false return false if @dispatch_framework_initialized @dispatch_framework_initialized ||=true if RUBY_VERSION =~ /1.9/ and not defined?(JRUBY_VERSION) begin require 'rhoconnect/async' register Rhoconnect::Synchrony rescue LoadError => e # if it fails here - Async can not be used settings.use_async_model = false warning_for_async_gems = "\n***** WARNING *****\nRhoconnect has detected that Ruby 1.9.x is used and tried to initialize Async Framework, but failed:\n\n \#{e.inspect}\n\nMake sure to include the following dependencies into your application's Gemfile:\n\nplatforms :ruby_19, :mingw_19 do\n gem 'rack-fiber_pool'\n gem 'async-rack'\nend\n\nAfter that, run 'bundle install' to install the necassary dependency gems.\n***** WARNING *****\n\n" puts warning_for_async_gems end else set :use_async_model, false end end |
.api4(resource, route_url, verb = :post, options = {}, &block) ⇒ Object
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 |
# File 'lib/rhoconnect/server.rb', line 221 def self.api4(resource, route_url, verb = :post, = {}, &block) deprecated_route = [:deprecated_route] .delete(:deprecated_route) # TODO: Re-work deprecation handling as soon as client is updated # the only reason we do criss-cross routing is because old-style routes # had one root and new-style routes now reside in separate controllers rc_handler = [:rc_handler] .delete(:rc_handler) rc_handler_method = nil if rc_handler rc_handler_method = "execute_#{rc_handler}_handler" invoke_hook(:handler_installed, self, rc_handler, verb, route_url, ) end unless deprecated_route.nil? deprecated_urls = deprecated_route[:url].is_a?(String) ? [deprecated_route[:url]] : deprecated_route[:url] deprecated_urls.each do |deprecated_url| d_verb = deprecated_route[:verb].to_sym dep_route_handler = Rhoconnect::DefaultServer.send(:generate_method, :dep_route_handler, &block) # build deprecation hash to be used later at run time for re-directing dep_info = {} dep_info[:klass] = self dep_info[:route_handler] = dep_route_handler dep_info[:rc_handler_method] = rc_handler_method dep_info[:verb] = verb dep_info[:route_url] = route_url #Rhoconnect::DefaultServer.paths[d_verb] ||= [] Rhoconnect::DefaultServer.paths(d_verb) << deprecated_url Rhoconnect::DefaultServer.deprecated_routes(d_verb)[deprecated_url] ||= {} Rhoconnect::DefaultServer.deprecated_routes(d_verb)[deprecated_url][self.name] = dep_info Rhoconnect::DefaultServer.send d_verb, deprecated_url, do klass = nil req_verb = env['REQUEST_METHOD'].downcase.to_sym req_path = env['PATH_INFO'] # retrieve controller-specific deprecation handler if params[:source_name] controller_name = "#{params[:source_name]}Controller" dep_info = Rhoconnect::DefaultServer.deprecated_routes(req_verb)[req_path][controller_name] if dep_info klass = dep_info[:klass] verb = dep_info[:verb] route_url = dep_info[:route_url] dep_route_handler = dep_info[:route_handler] rc_handler_method = dep_info[:rc_handler_method] end end mark_deprecated_call_and_reroute_api4(verb, route_url, req_verb, req_path, dep_route_handler, rc_handler_method, klass) end end end # turn block into UnboundMethod - so that we can bind it later with # particular Controller instance #self.paths[verb] ||= [] self.paths(verb) << route_url route_handler = send(:generate_method, :route_handler, &block) route verb.to_s.upcase, route_url, do execute_api_call(route_handler, rc_handler_method) end end |
.new ⇒ Object
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
# File 'lib/rhoconnect/server.rb', line 187 def new # by default, enable this feature if not settings.respond_to?(:use_async_model) or settings.use_async_model != false set :use_async_model, true end # this must be called first - because # it redefines some of the middleware _use_async_framework if settings.respond_to?(:stats) and settings.send(:stats) == true Rhoconnect.stats = true else Rhoconnect::Server.disable :stats Rhoconnect.stats = false end Rhoconnect::Server.settings.use_middleware #puts "Controller #{self.name} has been initialized with #{middleware.inspect}" super end |
.paths(verb = nil) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/rhoconnect/server.rb', line 36 def self.paths(verb = nil) @paths ||= {} return @paths if verb.nil? @paths[verb] ||= [] @paths[verb] end |
.set_default(setting, value) ⇒ Object
30 31 32 33 |
# File 'lib/rhoconnect/server.rb', line 30 def set_default(setting, value) @default_settings ||= {} @default_settings[setting] = value end |