haldish
v2.1.0
Published
Kotlin Multiplatform HAL client — HTTP, HAL parsing, URI templates
Maintainers
Readme
haldish
HAL (Hypertext Application Language) client for JavaScript — HTTP, HAL parsing (JSON/XML/YAML), and RFC 6570 URI template expansion. Compiled from the HALDiSh Kotlin Multiplatform library.
npm install haldishimport { JsHalClient, JsHeaders } from 'haldish';
const client = new JsHalClient();
// GET and parse
const res = await client.get('https://api.example.com/');
const root = JSON.parse(res.body);
// Expand an RFC 6570 template
client.varsAdd('name', 'Project A');
client.varsAdd('name', 'Project B');
client.varsSet('name_op', 'in');
const url = client.expandVars(root._links.projects.href);
// Custom headers
const headers = new JsHeaders().set('Authorization', 'Bearer token');
await client.get(url, headers);
client.close();require('haldish') works too, and TypeScript declarations ship with the package.
For the browser/WebAssembly build, see haldish-wasm.
Full documentation: https://github.com/C06A/HALDiSh_KMP
Apache-2.0
