Class: Qa::LinkedData::RequestHeaderService
- Inherits:
-
Object
- Object
- Qa::LinkedData::RequestHeaderService
- Defined in:
- app/services/qa/linked_data/request_header_service.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#request_id ⇒ Object
readonly
Returns the value of attribute request_id.
Instance Method Summary collapse
- #content_type_for_format ⇒ Object
-
#fetch_header ⇒ Object
Construct request parameters to pass to fetching a term (linked data module).
-
#initialize(request:, params:) ⇒ RequestHeaderService
constructor
A new instance of RequestHeaderService.
-
#search_header ⇒ Object
Construct request parameters to pass to search_query (linked data module).
Constructor Details
#initialize(request:, params:) ⇒ RequestHeaderService
params may have additional attribute-value pairs that are passed through via replacements (only configured replacements are used)
Returns a new instance of RequestHeaderService.
17 18 19 20 21 22 |
# File 'app/services/qa/linked_data/request_header_service.rb', line 17 def initialize(request:, params:) @request = request @params = params @request_id = request.request_id log_request end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
6 7 8 |
# File 'app/services/qa/linked_data/request_header_service.rb', line 6 def params @params end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
6 7 8 |
# File 'app/services/qa/linked_data/request_header_service.rb', line 6 def request @request end |
#request_id ⇒ Object (readonly)
Returns the value of attribute request_id.
6 7 8 |
# File 'app/services/qa/linked_data/request_header_service.rb', line 6 def request_id @request_id end |
Instance Method Details
#content_type_for_format ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'app/services/qa/linked_data/request_header_service.rb', line 57 def content_type_for_format case format when 'jsonld' 'application/ld+json' when 'n3' 'text/n3' when 'ntriples' 'application/n-triples' else 'application/json' end end |
#fetch_header ⇒ Object
Construct request parameters to pass to fetching a term (linked data module).
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/services/qa/linked_data/request_header_service.rb', line 43 def fetch_header header = {} header[:request] = request header[:request_id] = request_id header[:subauthority] = params.fetch(:subauthority, nil) header[:user_language] = user_language header[:performance_data] = performance_data? header[:format] = format header[:response_header] = response_header? header[:replacements] = replacements header end |
#search_header ⇒ Object
Construct request parameters to pass to search_query (linked data module).
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/services/qa/linked_data/request_header_service.rb', line 27 def search_header header = {} header[:request] = request header[:request_id] = request_id header[:subauthority] = params.fetch(:subauthority, nil) header[:user_language] = user_language header[:performance_data] = performance_data? header[:context] = context? header[:response_header] = response_header? header[:replacements] = replacements header end |