class
Amber::Schema::Parser::QueryParser
Defined in:
amber/schema/parsers/query_parser.crClass Method Summary
-
.parse_admitted_params(params : HTTP::Params | Hash(String, String) | URI::Params, budget : Amber::Router::Parsers::ParamBudget) : Hash(String, JSON::Any)
Nests params that budget has already admitted, such as the router's cached parse of this request's query string or body.
-
.parse_params_to_nested(params : HTTP::Params | Hash(String, String), limits : Amber::Configuration::ParamsConfig = Amber.settings.params) : Hash(String, JSON::Any)
Convert flat params to nested structure.
-
.parse_query_string(query_string : String, limits : Amber::Configuration::ParamsConfig = Amber.settings.params) : Hash(String, JSON::Any)
Parse query string into nested hash structure.
-
.parse_value(value : String) : JSON::Any
Try to parse value as JSON, number, or boolean
-
.set_nested_value(hash : Hash(String, JSON::Any), key : String, value : String | JSON::Any, budget : Amber::Router::Parsers::ParamBudget = Amber::Router::Parsers::ParamBudget.new)
Handle nested parameter keys like user[profile][name].
-
.set_nested_value(hash : Hash(String, JSON::Any), key : String, budget : Amber::Router::Parsers::ParamBudget, & : -> JSON::Any) : Bool
Sets the value the block returns at nested key, checking the key and reserving its array slot first, so a rejected key never reads or parses its value (such as an uploaded file).
-
.to_query_string(data : Hash(String, JSON::Any), prefix : String | Nil = nil) : String
Flatten nested hash to query string
Instance Method Summary
Instance methods inherited from class Amber::Schema::Parser::Base
can_parse?(value : JSON::Any) : Bool
can_parse?,
parse(value : JSON::Any) : JSON::Any
parse
Class Method Detail
Nests params that budget has already admitted, such as the router's cached parse of this request's query string or body. Counts are not charged again; indices, depth and padding are checked against the same budget so they stay cumulative for the request.
Convert flat params to nested structure.
Raises Amber::Exceptions::ParameterLimitExceeded when the params
exceed limits; see Amber::Configuration::ParamsConfig.
Parse query string into nested hash structure. Each pair is checked against limits as it is decoded.
Try to parse value as JSON, number, or boolean
Handle nested parameter keys like user[profile][name].
Pass the same budget for every parameter of one request so that its cumulative limits apply.
Sets the value the block returns at nested key, checking the key and reserving its array slot first, so a rejected key never reads or parses its value (such as an uploaded file). Returns whether the block ran; it does not run for a key that conflicts with an earlier value's type.
Flatten nested hash to query string