ImSQL
C++ 기반 SQL 자동화 및 라이선스 관리 엔진
Loading...
Searching...
No Matches
handler_base.hpp
Go to the documentation of this file.
1
8#pragma once
9
10#include <utils/utils.hpp>
11#include <string>
12#include <unordered_map>
13#include <nlohmann/json.hpp>
14
15namespace handler {
16
20enum class StatusCode {
21 _200 = 200,
22 _201 = 201,
23 _204 = 204,
24 _400 = 400,
25 _401 = 401,
26 _403 = 403,
27 _404 = 404,
28 _405 = 405,
29 _422 = 422,
30 _429 = 429,
31 _500 = 500
32};
33
45inline crow::response createCommonResponse(StatusCode status_code, const std::string& message = "") {
46 if (status_code == StatusCode::_204) {
47 return crow::response(static_cast<int>(status_code));
48 }
49
50 nlohmann::json res_json = {
51 {"message", message}
52 };
53
54 crow::response res(static_cast<int>(status_code));
55 res.set_header("Content-Type", "application/json");
56 res.write(res_json.dump());
57 return res;
58}
59
60} // namespace handler // end of HandlerBase
StatusCode
HTTP 상태 코드를 나타내는 열거형.
Definition handler_base.hpp:20
crow::response createCommonResponse(StatusCode status_code, const std::string &message="")
공통 HTTP 응답을 생성하는 함수.
Definition handler_base.hpp:45
다양한 범용 유틸리티 함수와 공통 설정을 포함하는 헤더 파일입니다.