14 #include <restinio/helpers/http_field_parsers/basics.hpp> 48 return base_type_t::operator()(actual)
66 return restinio::easy_parser::impl::symbol_producer_template_t<
67 is_token68_char_predicate_t >{};
89 return (to << v.value);
99 return produce< token68_t >(
100 produce< std::string >(
101 repeat( 1, N, token68_symbol_p() >> to_container() ),
102 repeat( 0, N, symbol_p(
'=') >> to_container() )
103 ) >> &token68_t::value
190 return { std::move(v), value_form_t::token };
193 return { std::move(v), value_form_t::quoted_string };
198 auto token68_seq = sequence(
199 token68_p() >> as_result(),
200 not_clause( any_symbol_p() >> skip() ) );
202 auto params_seq = maybe_empty_comma_separated_list_p< param_container_t >(
204 token_p() >> to_lower() >> ¶m_t::name,
208 produce< param_value_t >(
210 token_p() >> convert( token_to_v ) >> as_result(),
211 quoted_string_p() >> convert( qstring_to_v )
218 return produce< authorization_value_t >(
219 token_p() >> to_lower() >> &authorization_value_t::auth_scheme,
221 repeat( 1, N, space() ),
222 produce< auth_param_t >(
223 alternatives( token68_seq, params_seq )
224 ) >> &authorization_value_t::auth_param
240 return restinio::easy_parser::try_parse( what, make_parser() );
252 if(authorization_value_t::value_form_t::token == v.form)
255 to <<
'"' << v.value <<
'"';
264 return (to << v.name <<
'=' << v.value);
283 operator()(
const authorization_value_t::param_container_t & c )
const 287 for(
const auto & param : c )
300 std::visit( printer_t{ to }, p );
310 return (to << v.auth_scheme <<
' ' << v.auth_param);
expected_t< std::optional< string_view_t >, not_found_t > find_first(const parameter_with_optional_value_container_t &where, string_view_t what)
A helper function to find the first occurence of a parameter with the specified value.
static expected_t< authorization_value_t, restinio::easy_parser::parse_error_t > try_parse(string_view_t what)
An attempt to parse Authorization HTTP-field.
std::ostream & operator<<(std::ostream &to, const authorization_value_t::auth_param_t &p)
bool operator()(const char actual) const noexcept
value_form_t
An indicator of the source form of the value of a parameter.
std::string value
The value of a parameter.
std::ostream & operator<<(std::ostream &to, const authorization_value_t::param_value_t &v)
static auto make_parser()
A factory function for a parser of Authorization value.
param_value_t value
The value of a parameter.
std::enable_if< std::is_same< Parameter_Container, query_string_params_t >::value||std::is_same< Parameter_Container, router::route_params_t >::value, std::optional< Value_Type > >::type opt_value(const Parameter_Container ¶ms, string_view_t key)
Gets the value of a parameter specified by key wrapped in std::optional<Value_Type> if parameter exis...
A storage for a parameter with a name and a value.
value_form_t form
How this value was represented: as a token, or a quoted string?
The value of a parameter was specified as token.
The value of a parameter was specified as quoted_string.
std::string auth_scheme
A value of auth-scheme.
Tools for working with the value of Authorization HTTP-field.
A storage for the value of a parameter.
std::ostream & operator<<(std::ostream &to, const authorization_value_t &v)
std::ostream & operator<<(std::ostream &to, const token68_t &v)
std::string name
The name of a parameter.
A preducate for symbol_producer_template that checks that a symbol can be used inside token68 from RF...
std::ostream & operator<<(std::ostream &to, const authorization_value_t::param_t &v)
A structure for holding a value of token68 from RFC7235.
auth_param_t auth_param
A parameter for authorization.