Class: ElasticGraph::GraphQL::HTTPResponse
- Inherits:
-
Data
- Object
- Data
- ElasticGraph::GraphQL::HTTPResponse
- Defined in:
- lib/elastic_graph/graphql/http_endpoint.rb
Overview
Represents an HTTP response, containing:
-
status_code: an integer like 200.
-
headers: a hash with string keys and values containing HTTP response headers.
-
body: a string containing the response body.
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
Class Method Summary collapse
-
.error(status_code, message) ⇒ Object
Helper method for building an error response.
-
.json(status_code, body) ⇒ Object
Helper method for building a JSON response.
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body
213 214 215 |
# File 'lib/elastic_graph/graphql/http_endpoint.rb', line 213 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers
213 214 215 |
# File 'lib/elastic_graph/graphql/http_endpoint.rb', line 213 def headers @headers end |
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code
213 214 215 |
# File 'lib/elastic_graph/graphql/http_endpoint.rb', line 213 def status_code @status_code end |
Class Method Details
.error(status_code, message) ⇒ Object
Helper method for building an error response.
222 223 224 |
# File 'lib/elastic_graph/graphql/http_endpoint.rb', line 222 def self.error(status_code, ) json(status_code, {"errors" => [{"message" => }]}) end |
.json(status_code, body) ⇒ Object
Helper method for building a JSON response.
217 218 219 |
# File 'lib/elastic_graph/graphql/http_endpoint.rb', line 217 def self.json(status_code, body) new(status_code, {"Content-Type" => HTTPEndpoint::APPLICATION_JSON}, ::JSON.generate(body)) end |