HTTP client extension for LegionIO. Makes HTTP requests with support for JSON and XML content types via Faraday. Responses are automatically parsed based on the Content-Type header.
gem install lex-httpAll functions are in the Http runner and accept the following parameters:
| Function | Required | Optional |
|---|---|---|
get |
host |
uri, port, params, body |
post |
host |
uri, port, params, body |
put |
host |
uri, port, params, body |
patch |
host |
uri, port, params, body |
delete |
host |
uri, port, params, body |
head |
host |
uri, port, params, body |
options |
host |
uri, port, params, body |
status |
(none) | - |
Parameters:
host- Full base URL (e.g.https://api.example.com)uri- Path component (default:'')port- Override port (default:80)params- Query string parameters as a hashbody- Request body
Default timeouts (configured via default_settings):
open_timeout: 5 secondsread_timeout: 10 secondstimeout: 10 seconds
{"host": "https://api.example.com"}{"host": "http://192.168.1.1", "uri": "/api/v1/status", "port": 8080, "params": {"format": "json"}}{"host": "https://api.example.com", "uri": "/users", "body": {"name": "Alice"}}Use Legion::Extensions::Http::Client outside the full LegionIO framework. The client stores timeout defaults; each request specifies its own host.
require 'legion/extensions/http'
client = Legion::Extensions::Http::Client.new(open_timeout: 5, read_timeout: 10)
response = client.get(host: 'https://api.example.com', uri: '/status')- Ruby >= 3.4
- LegionIO framework (optional for standalone client usage)
faraday>= 2.0,multi_json,multi_xml
MIT