View Source Tesla.Middleware.MessagePack (tesla v1.8.0)

Encode requests and decode responses as MessagePack.

This middleware requires Msgpax as dependency.

Remember to add {:msgpax, ">= 2.3.0"} to dependencies. Also, you need to recompile Tesla after adding :msgpax dependency:

mix deps.clean tesla
mix deps.compile tesla

Examples

defmodule MyClient do
  use Tesla

  plug Tesla.Middleware.MessagePack
  # or
  plug Tesla.Middleware.MessagePack, engine_opts: [binary: true]
  # or
  plug Tesla.Middleware.MessagePack, decode: &Custom.decode/1, encode: &Custom.encode/1
end

Options

  • :decode - decoding function
  • :encode - encoding function
  • :encode_content_type - content-type to be used in request header
  • :decode_content_types - list of additional decodable content-types
  • :engine_opts - optional engine options

Summary

Functions

Decode response body as MessagePack.

Encode request body as MessagePack.

Functions

Decode response body as MessagePack.

It is used by Tesla.Middleware.DecodeMessagePack.

Encode request body as MessagePack.

It is used by Tesla.Middleware.EncodeMessagePack.