TeslaKeys.Middleware.Remapper (tesla_keys v0.2.0)
Tesla middleware for remapping request and response body keys.
This middleware will remap the body keys by their respective relations defined in the options before sending the request and after receiving the response. All unmapped keys will be kept as is when doing the convertion.
examples
Examples
defmodule MyClient do
use Tesla
plug TeslaKeys.Middleware.Remapper, keys: %{
# key expected by API => key you want to handle instead
"pong" => "ping",
"bar" => "foo",
"bye" => "hey"
}
# or if you are working with atom keys map
plug TeslaKeys.Middleware.Remapper, keys: [
# "key expected by API": :"key you want to handle instead"
pong: :ping,
bar: :foo,
bye: :hey
]
end
options
Options
:keys
- relation of keys expected by the API and that you want to handle