feat: initialize Lux package registry

- Add registry README with API documentation
- Add initial packages: json, http-client, testing
- Add package index.json for registry server

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-15 04:35:00 -05:00
commit 3df037cebb
11 changed files with 519 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
# 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