Skip to content

Commit

Permalink
docs: improve guide
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Aug 28, 2024
1 parent 77c0274 commit 99de09a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
4 changes: 3 additions & 1 deletion docs/userguides/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ ape plugins install .
For Ape's HTTP usage, such as requests made via `web3.py`, optionally specify extra request headers.

```yaml
request_header:
request_headers:
# NOTE: Only using Content-Type as an example; can be any header key/value.
Content-Type: application/json
```
Expand All @@ -210,6 +210,8 @@ node:
Content-Type: application/json
```
To learn more about how request headers work in Ape, see [this section of the Networking guide](./networks.html#request-headers).
## Testing
Configure your test accounts:
Expand Down
18 changes: 14 additions & 4 deletions docs/userguides/networks.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,17 @@ For the local network configuration, the default is `"max"`. Otherwise, it is `"
## Request Headers

There are several layers of request-header configuration.
Use the top-level request header config to configure headers for every request.
Also, EVM-based and custom-ecosystems offer their own `request_headers:` config that gets used whenever using that ecosystem (regardless of network or provider).
Then, each network, plugin or otherwise, has its own `request_headers:` config that gets used when using this network (regardless of provider).
Finally, providers (such as the default `node` provider) typically offer a `request_headers:` config that gets used whenever using this provider (regardless of what network you are connecting to).
They get merged into each-other in this order, with the exception being `User-Agent`, which has an append-behavior.

- Default Ape headers (includes `User-Agent`)
- Top-level configuration for headers (using `request_headers:` key)
- Per-ecosystem configuration
- Per-network configuration
- Per-provider configuration

Use the top-level `request_headers:` config to specify headers for every request.
Use ecosystem-level specification for only requests made when connected to that ecosystem.
Network and provider configurations work similarly; they are only used when connecting to that network or provider.

Here is an example using each layer:

Expand All @@ -367,6 +374,9 @@ node:
Provider-Level: "UseThisOnAllRequestsUsingNodeProvider"
```

When using `User-Agent`, it will not override Ape's default `User-Agent` nor will each layer override each-other's.
Instead, they are carefully appended to each other, allowing you to have a very customizable `User-Agent`.

## Local Network

The default network in Ape is the local network (keyword `"local"`).
Expand Down

0 comments on commit 99de09a

Please sign in to comment.