Skip to main content

No project description provided

Project description

polywrap-http-plugin

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 = client.invoke(
    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 = client.invoke(
    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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

polywrap_http_plugin-0.1.0a9.tar.gz (5.1 kB view hashes)

Uploaded Source

Built Distribution

polywrap_http_plugin-0.1.0a9-py3-none-any.whl (6.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page