class HttpTransport
Thin Net::HTTP wrapper for the JSON/API calls (catalog REST, Trino REST). Injected into the clients so tests can substitute a fake transport and never touch the network.
Public Instance Methods
Source
# File app/services/http_transport.rb, line 73 def delete(uri, headers: {}) perform(Net::HTTP::Delete.new(URI.parse(uri.to_s)), headers: headers, body: nil) end
Performs a DELETE request and parses the JSON response.
@param uri [String] the request URI @param headers [Hash] extra HTTP headers @return [Hash] the parsed JSON response @raise [ApiError] on non-success responses
Source
# File app/services/http_transport.rb, line 50 def get(uri, headers: {}) perform(Net::HTTP::Get.new(URI.parse(uri.to_s)), headers: headers, body: nil) end
Performs a GET request and parses the JSON response.
@param uri [String] the request URI @param headers [Hash] extra HTTP headers @return [Hash] the parsed JSON response @raise [ApiError] on non-success responses
# File app/services/http_transport.rb, line 61 def post(uri, body:, headers: {}) request = Net::HTTP::Post.new(URI.parse(uri.to_s)) request["Content-Type"] = "application/json" perform(request, headers: headers, body: body) end
Performs a POST request with a body and parses the JSON response.
@param uri [String] the request URI @param body [String] the request body @param headers [Hash] extra HTTP headers @return [Hash] the parsed JSON response @raise [ApiError] on non-success responses
# File app/services/http_transport.rb, line 78 def post_form(uri, body:, headers: {}) request = Net::HTTP::Post.new(URI.parse(uri.to_s)) request["Content-Type"] = "application/x-www-form-urlencoded" perform(request, headers: headers, body: body) end
The OAuth2 token endpoint expects form-urlencoded, not JSON.