WIP: 404 handling
This commit is contained in:
parent
ad1b8a6dd5
commit
c96300a2f4
@ -11,14 +11,28 @@ namespace seafire::resources
|
||||
{
|
||||
auto rep = common::invoke(resource, req, &R::get);
|
||||
|
||||
if (!rep) {
|
||||
auto select = [&]() -> decltype(rep)
|
||||
{
|
||||
if constexpr (representation::traits::is_optional_representation_v<decltype(rep)>) {
|
||||
if (!rep) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return representation::select(*rep, accepted_type);
|
||||
}
|
||||
else {
|
||||
return representation::select(rep, accepted_type);
|
||||
}
|
||||
};
|
||||
|
||||
auto selected_rep = select();
|
||||
|
||||
if (!selected_rep) {
|
||||
res.send(server::common_error_t::not_found);
|
||||
return;
|
||||
}
|
||||
|
||||
auto selected_rep = representation::select(*rep, accepted_type);
|
||||
|
||||
if (!check_preconditions(req, res, selected_rep))
|
||||
if (!check_preconditions(req, res, *selected_rep))
|
||||
return;
|
||||
|
||||
namespace rfc7231 = protocol::rfc7231;
|
||||
@ -41,7 +55,7 @@ namespace seafire::resources
|
||||
status = 201;
|
||||
|
||||
bool const send_content = kind != get_kind_t::head;
|
||||
representation::send(req, res, status, selected_rep, send_content);
|
||||
representation::send(req, res, status, *selected_rep, send_content);
|
||||
}
|
||||
|
||||
} // namespace seafire::resources
|
||||
|
@ -43,6 +43,10 @@ namespace seafire::resources::traits
|
||||
typename common::traits::function_traits<decltype(&R::get)>::return_type
|
||||
>
|
||||
||
|
||||
representation::traits::is_representation_v<
|
||||
typename common::traits::function_traits<decltype(&R::get)>::return_type
|
||||
>
|
||||
||
|
||||
representation::traits::is_optional_representation_v<
|
||||
typename common::traits::function_traits<decltype(&R::get)>::return_type
|
||||
>
|
||||
|
Loading…
x
Reference in New Issue
Block a user