# http-client HTTP client utilities for Lux. ## Installation ```bash lux pkg add http-client 0.1.0 ``` ## Usage ```lux import http-client as http fn main(): Unit with {Console, Http} = { // Simple GET request let body = http.get("https://api.example.com/data") Console.print(body) // GET and parse JSON let data = http.getJson("https://api.example.com/users") Console.print("Got " ++ toString(List.length(data)) ++ " users") // POST with JSON body let response = http.postJson( "https://api.example.com/users", Json.object([ ("name", JsonString("Alice")), ("email", JsonString("alice@example.com")) ]) ) // GET with query parameters let results = http.getWithParams( "https://api.example.com/search", [("q", "lux programming"), ("limit", "10")] ) } ``` ## API | Function | Description | |----------|-------------| | `get(url)` | GET request, return body | | `getJson(url)` | GET and parse as JSON | | `postJson(url, data)` | POST with JSON body | | `putJson(url, data)` | PUT with JSON body | | `delete(url)` | DELETE request | | `postJsonGetJson(url, data)` | POST JSON, parse response | | `getWithParams(url, params)` | GET with query parameters | | `urlEncode(s)` | URL-encode a string | | `buildQueryString(params)` | Build query string from pairs | ## License MIT