Skip to main content

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


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.0a6.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

polywrap_http_plugin-0.1.0a6-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file polywrap_http_plugin-0.1.0a6.tar.gz.

File metadata

  • Download URL: polywrap_http_plugin-0.1.0a6.tar.gz
  • Upload date:
  • Size: 5.2 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

Hashes for polywrap_http_plugin-0.1.0a6.tar.gz
Algorithm Hash digest
SHA256 944d0c2245c317dc730c19397d640b19c0de3a5937a59b824df3a5d6d9474055
MD5 a714cfa2afc5c0851de8fb7398b5db25
BLAKE2b-256 192928dd35b4c201967af6790854e4ea7a371487de5d9650aac8ad7e2b17b5e1

See more details on using hashes here.

Provenance

File details

Details for the file polywrap_http_plugin-0.1.0a6-py3-none-any.whl.

File metadata

File hashes

Hashes for polywrap_http_plugin-0.1.0a6-py3-none-any.whl
Algorithm Hash digest
SHA256 cf7d0a652109f698af08f830edab1aa18813ed93b6f079cb0fbe79217bd8f9f5
MD5 89f320ae94a63ef78d28c7373eb0e5eb
BLAKE2b-256 45bde02b6ced3ca9ebd374263b09bcbc584c09cef0216dd8f6ea30001b4dc1c2

See more details on using hashes here.

Provenance

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