Metadata-Version: 2.4
Name: urban-json-http
Version: 0.2.1
Summary: Plugin urban-json : appels HTTP depuis les templates (http / httpget).
Author-email: Gael Beard <gaelgael5@gmail.com>
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/gaelgael5/Jslt
Project-URL: Repository, https://github.com/gaelgael5/Jslt
Keywords: json,transform,template,jslt,http,rest,plugin
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Typing :: Typed
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: urban-json
Requires-Dist: httpx>=0.24
Dynamic: license-file

# urban-json-http

*Français · [English](https://github.com/gaelgael5/Jslt/blob/main/packages/urban-json-http/README.en.md)*

Plugin [urban-json](https://github.com/gaelgael5/Jslt) : appels **HTTP** depuis les
templates. L'appel est formalisé comme un objet **Fetch / `RequestInit`** (le
vocabulaire HTTP-en-JSON standard).

## Installation

```bash
pip install urban-json-http      # tire urban-json et httpx
```

`urban-json` découvre le plugin automatiquement via les entry points (`urban_json.functions`).

## Utilisation

```python
from urban_json import JsltTemplate

tpl = JsltTemplate.parse('''
{
  "r:": http({
    "method": "GET",
    "url": "https://api.example.com/users",
    "headers": { "Authorization": $.token },
    "query": { "page": 1 }
  }),
  "code": r:$.status,
  "users": r:$.body.items
}
''')
tpl.transform({"token": "Bearer xyz"})
```

- `http(request)` — `request` : `{ method, url, headers, query, body, timeout }`.
  Renvoie `{ status, headers, body }` ; `body` est le JSON parsé si la réponse est
  du JSON, sinon le texte.
- `httpget(url, headers)` — convenance GET renvoyant directement le `body`.

Le corps (`body`) de la requête est envoyé en **JSON** si c'est un objet ou un
tableau, sinon tel quel. Verbe par défaut : `GET`. Timeout par défaut : 30 s
(surchargeable via `"timeout"`).

## Sécurité

`http` réalise de **vraies requêtes réseau**. Méfiez-vous des URL construites à
partir de données non fiables (SSRF). Un timeout par défaut est appliqué.

## Licence

Apache-2.0.
