5 #include <openssl/ssl.h>
13 Request(std::string headers
, std::string body
);
14 Request(std::string url
);
16 Link::Request
* SetURL(std::string url
),
17 * SetMethod(std::string method
),
18 * SetHeader(std::string key
, std::string value
),
19 * SetCookie(std::string key
, std::string value
),
20 * SetParam(std::string key
, std::string value
),
21 * SetBody(std::string body
),
22 * SetPath(std::string path
),
23 * SetProtocol(std::string protocol
),
24 * SetDomain(std::string domain
),
25 * SetVersion(std::string version
),
26 * SetHeadersRaw(std::string headersRaw
),
27 * SetRawHeader(std::string key
, std::string value
),
28 * SetIP(std::string ip
),
33 GetHeader(std::string key
),
34 GetRawHeader(std::string key
),
35 GetCookie(std::string key
),
36 GetParam(std::string key
),
44 std::map
<std::string
, std::string
> GetParams();
48 std::string
GetRawHeaders(), GetRawParams(), GetRawBody();
50 std::map
<std::string
, std::string
> headers
, cookies
, params
;
51 std::string body
, protocol
, path
, domain
, url
, method
, version
, ip
;
60 Response(std::string headers
, std::string body
);
62 Response
* SetHeader(std::string key
, std::string value
),
63 * SetBody(std::string body
),
64 * SetHeadersRaw(std::string headersRaw
),
65 * SetRawHeader(std::string key
, std::string value
),
66 * SetStatus(int status
),
67 * SetVersion(std::string version
),
69 * SetInstanceType(std::string type
);
71 std::string
GetHeader(std::string key
),
77 bool InstanceOf(std::string type
);
79 std::map
<std::string
, std::string
> headers
;
80 std::string body
, headersRaw
, version
, instanceType
;
88 Client(Request
* request
);
89 Link::Response
* Send();
91 Request
* SetRequest(Request
* request
);
93 Request
* GetRequest();
94 Response
* GetResponse();
97 int Write(const void* buf
, size_t count
);
98 int Read(void* buf
, size_t count
);
99 bool getChunkSize(int& remaining
, std::string
& body
);
113 Server
* SetPort(int port
),
116 * EnableMultiThreading(),
117 * DisableMultiThreading(),
119 * EnableSSL(std::string certPath
, std::string keyPath
),
120 * Get(std::string path
, std::function
<void(Request
*, Response
*)> callback
),
121 * Post(std::string path
, std::function
<void(Request
*, Response
*)> callback
),
122 * Route(std::string method
, std::string path
, std::function
<void(Request
*, Response
*)> callback
),
123 * Error(int status
, std::function
<void(Request
*, Response
*)> callback
),
124 * SetStaticPages(std::string path
),
125 * SetStartMessage(std::string message
),
126 * Use(std::function
<void(Request
*, Response
*, Server
*)> middleware
);
129 std::map
<std::vector
<std::string
>, std::function
<void(Request
*, Response
*)>> GetCallbacks();
130 std::vector
<std::function
<void(Request
*, Response
*, Server
*)>> GetMiddlewares();
131 std::vector
<std::string
> GetStaticPages();
132 std::map
<int, std::function
<void(Request
*, Response
*)>> GetErrors();
133 bool IsRunning(), IsMultiThreaded(), IsSSL(), IsDebugging();
134 std::string
GetStaticPagesDirectory();
139 bool running
, sslEnabled
, multiThreaded
, debugging
;
140 std::string certPath
, keyPath
, staticPages
, startMessage
;
141 std::map
<std::vector
<std::string
>, std::function
<void(Request
*, Response
*)>> callbacks
;
142 std::vector
<std::function
<void(Request
*, Response
*, Server
*)>> middlewares
;
143 std::map
<int, std::function
<void(Request
*, Response
*)>> errors
;
150 Thread(Server
* server
, int sock
, bool sslEnabled
);
151 Thread(Server
* server
, SSL
* ssl
, bool sslEnabled
);
152 void SetIP(std::string ip
), Run();
154 int Write(const void* buf
, size_t count
);
155 int Read(void* buf
, size_t count
);
165 Target(std::string host
, std::string target
);
166 Target
* AddHost(std::string host
);
167 std::vector
<std::string
> GetHosts();
168 std::string
GetTarget();
171 std::vector
<std::string
> hosts
;
178 Proxy(std::vector
<Target
*> targets
);
179 Proxy
* AddTarget(Target
* target
), *Start(), *EnableHTTPRedirects();
180 std::vector
<Target
*> GetTargets();
183 std::vector
<Target
*> targets
;
187 std::string
Status(int status
);
188 std::string
GetMIMEType(std::string path
);