annotation

HTTP::Param

An HTTP parameter annotation.

Options:

  • key -- a key to use for (de)serializing. By default all possible variations of the instance variable name are used (i.e. "foo_bar", "fooBar", "FooBar", "foo-bar" and "Foo-Bar" for a @foo_bar variable)
  • converter -- a converter to use for casting. Some types implement converter forwarding, for example, Array:
require "http-params-parseable"
require "http-params-parseable/ext/time/epoch_converter"

struct MyParams
  include HTTP::Params::Serializable

  @[HTTP::Param(converter: Time::EpochConverter, key: "theTime")]
  getter time : Array(Time)
end

params = MyParams.from_query("theTime[]=1544958806")
pp params.time.class # => Array(Time)