Skip to content

Custom params encoders

Compare
Choose a tag to compare
@mamantoha mamantoha released this 23 Jan 11:07
· 201 commits to master since this release

What's Changed

  • Tested with Crystal 1.3.0

  • Accept Float32 and Float64 as params value by @mamantoha in #166

  • Add read_timeout support by @kates in #169

  • Add custom params encoders by @mamantoha in #167
    (thanks @cyangle for the idea in #162)

    It is now possible to use a custom params encoder. For example Crest::NestedParamsEncoder:

    response = Crest.post(
      "http://httpbin.org/post",
      {"size" => "small", "topping" => ["bacon", "onion"]},
      params_encoder: Crest::NestedParamsEncoder
    )
    # => curl -X POST http://httpbin.org/post -d 'size=small&topping=bacon&topping=onion' -H 'Content-Type: application/x-www-form-urlencoded'

    By defaulf Crest::FlatParamsEncoder is used:

    response = Crest.post(
      "http://httpbin.org/post",
      {"size" => "small", "topping" => ["bacon", "onion"]}
    )
    # => curl -X POST http://httpbin.org/post -d 'size=small&topping[]=bacon&topping[]=onion' -H 'Content-Type: application/x-www-form-urlencoded'

New Contributors

Full Changelog: v1.0.1...v1.1.0