mirror of
https://github.com/yhirose/cpp-httplib
synced 2024-11-21 14:29:10 -07:00
Made Response argument 'const'.
This commit is contained in:
parent
b5ae7d0e7a
commit
1b2f37e241
2 changed files with 6 additions and 5 deletions
|
@ -24,7 +24,7 @@ std::string dump_headers(const MultiMap& headers)
|
|||
return s;
|
||||
}
|
||||
|
||||
std::string log(const Request& req, Response& res)
|
||||
std::string log(const Request& req, const Response& res)
|
||||
{
|
||||
std::string s;
|
||||
char buf[BUFSIZ];
|
||||
|
@ -88,7 +88,7 @@ int main(void)
|
|||
res.set_content(buf, "text/html");
|
||||
});
|
||||
|
||||
svr.set_logger([](const Request& req, Response& res) {
|
||||
svr.set_logger([](const Request& req, const Response& res) {
|
||||
printf("%s", log(req, res).c_str());
|
||||
});
|
||||
|
||||
|
|
|
@ -84,6 +84,7 @@ struct Response {
|
|||
class Server {
|
||||
public:
|
||||
typedef std::function<void (const Request&, Response&)> Handler;
|
||||
typedef std::function<void (const Request&, const Response&)> Logger;
|
||||
|
||||
Server();
|
||||
~Server();
|
||||
|
@ -92,7 +93,7 @@ public:
|
|||
void post(const char* pattern, Handler handler);
|
||||
|
||||
void set_error_handler(Handler handler);
|
||||
void set_logger(Handler logger);
|
||||
void set_logger(Logger logger);
|
||||
|
||||
bool listen(const char* host, int port);
|
||||
void stop();
|
||||
|
@ -109,7 +110,7 @@ private:
|
|||
Handlers get_handlers_;
|
||||
Handlers post_handlers_;
|
||||
Handler error_handler_;
|
||||
Handler logger_;
|
||||
Logger logger_;
|
||||
};
|
||||
|
||||
class Client {
|
||||
|
@ -586,7 +587,7 @@ inline void Server::set_error_handler(Handler handler)
|
|||
error_handler_ = handler;
|
||||
}
|
||||
|
||||
inline void Server::set_logger(Handler logger)
|
||||
inline void Server::set_logger(Logger logger)
|
||||
{
|
||||
logger_ = logger;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue