postwoman/postwoman.toml

57 lines
1.9 KiB
TOML
Raw Normal View History

2024-10-19 22:22:12 +02:00
[client] # HTTP client configuration
2024-10-20 15:29:10 +02:00
user_agent = "postwoman@sample/0.4.0"
2024-10-20 01:33:20 +02:00
timeout = 60 # max time for each request to complete, in seconds
redirects = 5 # allow up to five redirects, defaults to none
base = "https://api.alemi.dev" # all route urls will be appended to this base
2024-10-19 04:13:42 +02:00
2024-10-19 22:22:12 +02:00
[env] # these will be replaced in routes options. environment vars overrule these
PW_TOKEN = "set-me-as-and-environment-variable!"
2024-10-19 04:12:46 +02:00
[route.healthcheck] # the simplest possible route: just name and path
path = "/"
2024-10-19 22:02:05 +02:00
2024-10-19 04:12:46 +02:00
[route.debug]
path = "/debug"
2024-10-19 22:22:12 +02:00
method = "PUT" # specify request method
query = [ # specify query parameters in a more friendly way
2024-10-19 19:24:12 +02:00
"body=json",
"cache=0"
]
2024-10-19 22:22:12 +02:00
headers = [ # add custom headers to request
"Content-Type: application/json",
"Authorization: Bearer ${PW_TOKEN}",
]
body = { hello = "world!", success = true } # body can be a bare string, or an inline table (will be converted to json)
extract = { type = "body" } # get the whole response body, this is the default extractor
2024-10-19 22:22:12 +02:00
[route.benchmark]
path = "/look/into/the/void"
2024-10-19 22:22:12 +02:00
extract = { type = "discard" } # if you don't care about the output, discard it!
[route.notfound]
path = "https://cdn.alemi.dev/does-not-exist"
absolute = true # mark as absolute to avoid composing with client base url
status = 404 # it's possible to specify expected status code, will fail if doesn't match
2024-10-19 22:22:12 +02:00
extract = { type = "regex", pattern = 'nginx/[0-9\.]+' } # extract from response with regex
2024-10-19 04:12:46 +02:00
2024-10-19 04:13:42 +02:00
[route.payload]
path = "/debug"
2024-10-19 04:13:42 +02:00
method = "POST"
body = '''{
"complex": {
"json": "payloads",
"can": "be",
"expressed": "this",
"way": true
}
}'''
extract = ".path" # extract from json responses with JQ syntax (default extractor), equivalent to `{ type = "jq", query = ".path" }`
expect = "/debug" # if extracted result doesn't match, this route will return an error
2024-10-19 04:13:42 +02:00
2024-10-19 04:12:46 +02:00
[route.cookie]
path = "/getcookie"
2024-10-19 04:12:46 +02:00
method = "GET"
2024-10-19 22:22:12 +02:00
extract = { type = "header", key = "Set-Cookie" } # get a specific response header, ignoring body