Skip to content

struct Athena::Framework::Controller::ValueResolvers::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::Controller::ValueResolvers::Interface

Constructors#

Methods#

#initialize#

View source

#resolve(request : ATH::Request, parameter : ATH::Controller::ParameterMetadata)#

Returns a value resolved from the provided request and parameter if possible, otherwise returns nil if no parameter could be resolved.

View source