View Source Tesla.Middleware.Curl (TeslaCurl v1.3.0)
A middleware for the Tesla HTTP client that logs requests expressed in Curl.
Parses Tesla.Env structs into a curl command and logs it. This is useful for debugging requests and responses.
examples
Examples
defmodule MyClient do
use Tesla
plug Tesla.Middleware.Curl, follow_redirects: true, redact_fields: ["api_token", "authorization"]
end
options
Options
:follow_redirects
- boolean, will add the-L
flag to the curl command:redact_fields
- a list of keys or regex capture groups to redact from the request body:compressed
- boolean, will add the--compressed
flag to the curl command:logger_level
- the level at which to log the curl command, as an atom. Must be one of -:emergency
,:alert
,:critical
,:error
,:warning
,:notice
,:info
,:debug
Link to this section Summary
Functions
Serves as the main entrypoint to the middleware. Handles this middleware and calls the next piece of middleware in the chain.
Calls the function to construct the curl command and logs it. If an error occurs, it will be logged, and the request will continue as normal. This can be used as a standalone function if you want to log a curl command without using the middleware.
Link to this section Types
@type method() :: :head | :get | :delete | :trace | :options | :post | :put | :patch
Link to this section Functions
@spec call(Tesla.Env.t(), Tesla.Env.stack(), keyword() | nil) :: Tesla.Env.result()
Serves as the main entrypoint to the middleware. Handles this middleware and calls the next piece of middleware in the chain.
@spec log(Tesla.Env.t(), keyword() | nil) :: :ok
Calls the function to construct the curl command and logs it. If an error occurs, it will be logged, and the request will continue as normal. This can be used as a standalone function if you want to log a curl command without using the middleware.