Class: ActiveRecordApi::Rest::RequestUrlGenerator
- Inherits:
-
Object
- Object
- ActiveRecordApi::Rest::RequestUrlGenerator
- Includes:
- ActiveAttr::Model
- Defined in:
- lib/active_record_api/rest/request_url_generator.rb
Instance Method Summary collapse
- #current_url ⇒ Object
- #micro_service_prefix ⇒ Object
- #new_params ⇒ Object
- #next_url ⇒ Object
- #protocol ⇒ Object
Instance Method Details
#current_url ⇒ Object
23 24 25 |
# File 'lib/active_record_api/rest/request_url_generator.rb', line 23 def current_url "#{protocol}#{host_with_port}#{micro_service_prefix}#{path}" end |
#micro_service_prefix ⇒ Object
27 28 29 |
# File 'lib/active_record_api/rest/request_url_generator.rb', line 27 def micro_service_prefix request.headers['HTTP_X_REAL_PATH'].sub(path, '') if request.headers['HTTP_X_REAL_PATH'].present? end |
#new_params ⇒ Object
19 20 21 |
# File 'lib/active_record_api/rest/request_url_generator.rb', line 19 def new_params query_parameters.dup.merge('page' => page + 1) end |
#next_url ⇒ Object
14 15 16 17 |
# File 'lib/active_record_api/rest/request_url_generator.rb', line 14 def next_url return if total_count == 0 || total_count <= (page + 1) * limit "#{current_url}?#{new_params.to_param}" end |
#protocol ⇒ Object
31 32 33 |
# File 'lib/active_record_api/rest/request_url_generator.rb', line 31 def protocol Rails.env.development? ? 'http://' : 'https://' end |