Maxwell.Middleware.EncodeJson (maxwell v2.4.0) View Source

Encode request's body to json when request's body is not nil

It will auto add %{'Content-Type': 'application/json'} to request's headers

Default json_lib is Poison

Examples

  # Client.ex
  use Maxwell.Builder ~(get)a
  middleware Maxwell.Middleware.EncodeJson

  # OR

  middleware Maxwell.Middleware.EncodeJson,
    encode_content_type: "application/json",
    encode_func: &other_json_lib.encode/1