2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
42#ifndef EXPRESS_RESPONSE_H
43#define EXPRESS_RESPONSE_H
45namespace web::http::server {
54#ifndef DOXYGEN_SHOULD_SKIP_THIS
60#include <nlohmann/json_fwd.hpp>
69 explicit Response(
const std::shared_ptr<web::http::server::Response>& response)
noexcept;
71 explicit Response(Response&) =
delete;
72 explicit Response(Response&&)
noexcept =
delete;
74 Response& operator=(Response&) =
delete;
75 Response& operator=(Response&&)
noexcept =
delete;
79 web::http::server::SocketContext* getSocketContext()
const;
81 void json(
const nlohmann::json& json);
83 void download(
const std::string& file,
const std::function<
void(
int)>& onError);
84 void download(
const std::string& file,
const std::string& fileName,
const std::function<
void(
int)>& onError);
86 void redirect(
const std::string& loc);
87 void redirect(
int state,
const std::string& loc);
89 void sendStatus(
int state);
91 Response& attachment(
const std::string& fileName =
"");
92 Response& location(
const std::string& loc);
93 Response& vary(
const std::string& field);
96 std::shared_ptr<web::http::server::Response> responseBase;
100 Response& status(
int status);
101 Response& append(
const std::string& field,
const std::string& value);
102 Response& set(
const std::string& field,
const std::string& value,
bool overwrite =
true);
103 Response& set(
const std::map<std::string, std::string>& headers,
bool overwrite =
true);
104 Response& type(
const std::string& type);
105 Response& cookie(
const std::string& name,
const std::string& value,
const std::map<std::string, std::string>& options = {});
106 Response& clearCookie(
const std::string& name,
const std::map<std::string, std::string>& options = {});
107 Response& setTrailer(
const std::string& field,
const std::string& value,
bool overwrite =
true);
109 void send(
const char* chunk, std::size_t chunkLen);
110 void send(
const std::string& chunk);
111 void upgrade(
const std::shared_ptr<Request>& request,
const std::function<
void(
const std::string)>& status);
113 void sendFile(
const std::string& file,
const std::function<
void(
int)>& callback);
115 Response& sendHeader();
116 Response& sendFragment(
const char* chunk, std::size_t chunkLen);
117 Response& sendFragment(
const std::string& chunk);
119 const std::string& header(
const std::string& field);
#define DECLARE_ROUTER_REQUESTMETHOD(METHOD)
static express::Router getRouter()
static WebApp getWebApp(const std::string &name)
static WebApp getWebApp(const std::string &name)
int main(int argc, char *argv[])