Browse Source

set default http response to not found

master
Jørgen Sverre Lien Sellæg 5 years ago
parent
commit
6532a267fe
  1. 2
      include/http.hpp
  2. 8
      src/http.cpp
  3. 6
      src/store.cpp

2
include/http.hpp

@ -14,4 +14,6 @@ public:
static void bad_json(std::shared_ptr<HttpsServer::Response> response);
static void bad_object(std::shared_ptr<HttpServer::Response> response);
static void bad_object(std::shared_ptr<HttpsServer::Response> response);
static void not_found(std::shared_ptr<HttpServer::Response> response);
static void not_found(std::shared_ptr<HttpsServer::Response> response);
};

8
src/http.cpp

@ -48,3 +48,11 @@ void response::bad_object(std::shared_ptr<HttpsServer::Response> response) {
bad_object_msg.dump(),
{header_access_control, header_application_data});
}
void response::not_found(std::shared_ptr<HttpsServer::Response> response) {
return response->write(Status::client_error_not_found);
}
void response::not_found(std::shared_ptr<HttpServer::Response> response) {
return response->write(Status::client_error_not_found);
}

6
src/store.cpp

@ -59,11 +59,7 @@ int Application::run() {
http_server.default_resource["GET"] =
[&](std::shared_ptr<HttpServer::Response> response, ...) {
if (https_server) {
return response::https_required(response);
}
response->write(Status::success_ok, store.dump(),
{header_access_control, header_application_data});
return response::not_found(response);
};
http_server.default_resource["POST"] =

Loading…
Cancel
Save