Skip to content

struct Athena::Framework::Arguments::Resolvers::DefaultValue
inherits Struct #

Resolves the default value of a controller action parameter if no other value was provided; using nil if the parameter does not have a default value, but is nilable.

require "athena"

class ExampleController < ATH::Controller
  @[ARTA::Get("/default")]
  def default(id : Int32 = 123) : Int32
    id
  end

  @[ARTA::Get("/nilable")]
  def nilable(id : Int32?) : Int32?
    id
  end
end

ATH.run

# GET /default # => 123
# GET /nilable # => null

Included modules

Athena::Framework::Arguments::Resolvers::Interface

Constructors#

Methods#

#initialize#

View source

#resolve(request : ATH::Request, argument : ATH::Arguments::ArgumentMetadata)#

Returns a value resolved from the provided request and argument.

View source

#supports?(request : ATH::Request, argument : ATH::Arguments::ArgumentMetadata) : Bool#

Returns true if self is able to resolve a value from the provided request and argument.

View source