Skip to content

Commit 99e3239

Browse files
authored
docs: add http example (#56)
1 parent 36a02ff commit 99e3239

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,22 @@ extism call plugin.wasm logStuff --wasi --log-level=info
239239
# => 2023/10/17 14:25:00 Hello, World!
240240
```
241241

242+
### HTTP
243+
244+
HTTP calls can be made using `Http.request`:
245+
246+
```python
247+
import extism
248+
249+
@extism.plugin_fn
250+
def call_http():
251+
url = "https://jsonplaceholder.typicode.com/todos/1"
252+
response = Http.request(url, meth="GET")
253+
if response.status_code != 200:
254+
raise Exception(f"Got non 200 response {response.status_code}")
255+
extism.output_str(response.data_str())
256+
```
257+
242258
### Using Host Functions
243259

244260
You can defer logic to host functions from your plugin code.

0 commit comments

Comments
 (0)