Project

lex-http

0.0
No release in over 3 years
Connections LegionIO to any HTTP source
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

 Project Readme

lex-http

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.

Installation

gem install lex-http

Functions

All 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 hash
  • body - Request body

Default timeouts (configured via default_settings):

  • open_timeout: 5 seconds
  • read_timeout: 10 seconds
  • timeout: 10 seconds

Example Task Payloads

{"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"}}

Standalone Client

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')

Requirements

  • Ruby >= 3.4
  • LegionIO framework (optional for standalone client usage)
  • faraday >= 2.0, multi_json, multi_xml

License

MIT