Skip to content

Commit

Permalink
throw not_found in case of not found, allows to catch this with error…
Browse files Browse the repository at this point in the history
… handler
  • Loading branch information
mhekkel committed Jan 2, 2024
1 parent d30e16b commit ecd1c5a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib-http/src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,22 @@ void basic_server::handle_request(asio_ns::ip::tcp::socket &socket, request &req
}

// do the actual work.
bool processed = false;
for (auto c : m_controllers)
{
if (not c->path_matches_prefix(req.get_uri()))
continue;

if (c->dispatch_request(socket, req, rep))
{
processed = true;
break;
}
}

if (not processed)
throw not_found;

if (method == "HEAD" or method == "OPTIONS")
rep.set_content("", rep.get_content_type());
else if (csrf_is_new)
Expand Down

0 comments on commit ecd1c5a

Please sign in to comment.