No project description provided
Project description
@polywrap/http-plugin-js
Http plugin currently supports two different methods GET
and POST
. Similar to calling axios, when defining request you need to specify a response type. Headers and query parameters may also be defined.
Response Types
TEXT
- The server will respond with text, the HTTP plugin will return the text as-is.
BINARY
- The server will respond with binary data (bytes), the HTTP plugin will encode as a base64 string and return it.
GET request
Below is sample invocation of the GET
request with custom request headers and query parameters (urlParams
).
result = await client.invoke(
InvokerOptions(
uri="wrap://ens/http.polywrap.eth",
method="get",
args={
"url": "http://www.example.com/api",
"request": {
"responseType": "TEXT",
"urlParams": [{"key": "query", "value": "foo"}],
"headers": [{"key": "X-Request-Header", "value": "req-foo"}],
},
},
)
)
POST request
Below is sample invocation of the POST
request with custom request headers and query parameters (urlParams
). It is also possible to set request body as shown below.
response = await client.invoke(
InvokerOptions(
uri="wrap://ens/http.polywrap.eth",
method="post",
args={
"url": "http://www.example.com/api",
"request": {
"responseType": "TEXT",
"urlParams": [{"key": "query", "value": "foo"}],
"headers": [{"key": "X-Request-Header", "value": "req-foo"}],
"body": "{data: 'test-request'}",
}
}
)
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file polywrap_http_plugin-0.1.0a5.tar.gz
.
File metadata
- Download URL: polywrap_http_plugin-0.1.0a5.tar.gz
- Upload date:
- Size: 2.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.10.11 Linux/5.15.0-1036-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5501bc8cf66b0b792cf50ed7265b9b84e817215e3a18101e7f351c55ec20e643 |
|
MD5 | 47735f2da3d01559f344c5b47f2c7b3e |
|
BLAKE2b-256 | 557a3404090b02d8175142a5adccd3c166ed593b76066be0d2d5e10dd71b8f75 |
Provenance
File details
Details for the file polywrap_http_plugin-0.1.0a5-py3-none-any.whl
.
File metadata
- Download URL: polywrap_http_plugin-0.1.0a5-py3-none-any.whl
- Upload date:
- Size: 2.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.10.11 Linux/5.15.0-1036-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa72adee0769d4a029cbc05583110ff1df69a29b05fdb8afddb61776ec0fb8cb |
|
MD5 | 47ae40e243a54be594a2dddb2a621c45 |
|
BLAKE2b-256 | 01795527353a1d3c278914b518ecb859d3e11315c16e5f6451ceb2a6ac6cd9d2 |