0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-27 11:18:51 +02:00

ircd::http: Simplify interface w/ util::closure_bool.

This commit is contained in:
Jason Volk 2023-02-23 12:53:33 -08:00
parent 9eec649b4d
commit a104e44e3e
2 changed files with 6 additions and 23 deletions

View file

@ -223,7 +223,7 @@ struct ircd::http::query
struct ircd::http::query::string struct ircd::http::query::string
:string_view :string_view
{ {
using closure = std::function<bool (const query &)>; using closure = util::function_bool<const query &>;
bool for_each(const closure &) const; bool for_each(const closure &) const;
bool for_each(const string_view &key, const closure &) const; bool for_each(const string_view &key, const closure &) const;
@ -271,19 +271,17 @@ struct ircd::http::header
struct ircd::http::headers struct ircd::http::headers
:string_view :string_view
{ {
using closure = std::function<void (const header &)>; using closure = util::function_bool<const header &>;
using closure_bool = std::function<bool (const header &)>;
static const string_view terminator; // "\r\n\r\n" static const string_view terminator; // "\r\n\r\n"
bool for_each(const closure_bool &) const; bool for_each(const closure &) const;
string_view operator[](const string_view &key) const; string_view operator[](const string_view &key) const;
string_view at(const string_view &key) const; string_view at(const string_view &key) const;
bool has(const string_view &key) const; bool has(const string_view &key) const;
using string_view::string_view; using string_view::string_view;
headers(parse::capstan &, closure_bool); headers(parse::capstan &, closure = {});
headers(parse::capstan &, const closure & = {});
headers() = default; headers() = default;
friend bool has(const headers &, const string_view &key); friend bool has(const headers &, const string_view &key);

View file

@ -652,22 +652,7 @@ ircd::http::headers::terminator
}; };
ircd::http::headers::headers(parse::capstan &pc, ircd::http::headers::headers(parse::capstan &pc,
const closure &c) closure c)
:headers
{
pc, closure_bool{[&c](const auto &header)
{
if(c)
c(header);
return true;
}}
}
{
}
ircd::http::headers::headers(parse::capstan &pc,
closure_bool c)
:string_view{[&pc, &c] :string_view{[&pc, &c]
() -> string_view () -> string_view
{ {
@ -729,7 +714,7 @@ const
} }
bool bool
ircd::http::headers::for_each(const closure_bool &closure) ircd::http::headers::for_each(const closure &closure)
const const
{ {
if(empty()) if(empty())