class Amber::Schema::Parser::QueryParser

Defined in:

amber/schema/parsers/query_parser.cr

Class Method Summary

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

def self.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. Counts are not charged again; indices, depth and padding are checked against the same budget so they stay cumulative for the request.


[View source]
def self.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.

Raises Amber::Exceptions::ParameterLimitExceeded when the params exceed limits; see Amber::Configuration::ParamsConfig.


[View source]
def self.parse_query_string(query_string : String, limits : Amber::Configuration::ParamsConfig = Amber.settings.params) : Hash(String, JSON::Any) #

Parse query string into nested hash structure. Each pair is checked against limits as it is decoded.


[View source]
def self.parse_value(value : String) : JSON::Any #

Try to parse value as JSON, number, or boolean


[View source]
def self.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].

Pass the same budget for every parameter of one request so that its cumulative limits apply.


[View source]
def self.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). Returns whether the block ran; it does not run for a key that conflicts with an earlier value's type.


[View source]
def self.to_query_string(data : Hash(String, JSON::Any), prefix : String | Nil = nil) : String #

Flatten nested hash to query string


[View source]

Instance Method Detail

def can_parse?(value : JSON::Any) : Bool #

[View source]
def parse(value : JSON::Any) : JSON::Any #

[View source]