You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
2.2 KiB

5 years ago
#include <http.hpp>
#include <json.hpp>
const auto https_required_msg = json::object({
{"message", "100: Your server is configured to use https, but a "
"request on http was received."},
});
const auto bad_json_msg = json::object({
{"message", "101: Your request was not a valid JSON document."},
});
const auto bad_object_msg = json::object({
{"message", "102: Your request was not a valid store."},
});
void response::https_required(std::shared_ptr<HttpServer::Response> response) {
return response->write(Status::client_error_bad_request,
https_required_msg.dump(),
{header_access_control, header_application_data});
}
void response::https_required(std::shared_ptr<HttpsServer::Response> response) {
return response->write(Status::client_error_bad_request,
https_required_msg.dump(),
{header_access_control, header_application_data});
}
void response::bad_json(std::shared_ptr<HttpServer::Response> response) {
return response->write(Status::client_error_bad_request, bad_json_msg.dump(),
{header_access_control, header_application_data});
}
void response::bad_json(std::shared_ptr<HttpsServer::Response> response) {
return response->write(Status::client_error_bad_request, bad_json_msg.dump(),
{header_access_control, header_application_data});
}
void response::bad_object(std::shared_ptr<HttpServer::Response> response) {
return response->write(Status::client_error_bad_request,
bad_object_msg.dump(),
{header_access_control, header_application_data});
}
void response::bad_object(std::shared_ptr<HttpsServer::Response> response) {
return response->write(Status::client_error_bad_request,
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);
}