-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathserver_stats.hpp
33 lines (24 loc) · 1020 Bytes
/
server_stats.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef SERVER_STATS_H
#define SERVER_STATS_H
#include <boost/thread/mutex.hpp>
#include "request_handler.hpp"
namespace http {
namespace server {
class ServerStats {
public:
static ServerStats& getInstance();
void insertHandler(const std::string& prefix, const std::string& handler_name);
void insertRequest(const std::string& url, Response::ResponseCode response);
int getNumRequests();
void clearAllEntries();
std::vector<std::pair<std::string, std::string>> getHandlers() const;
std::vector<std::pair<std::string, Response::ResponseCode>> getRequests() const;
boost::mutex sync_mutex;
private:
ServerStats() {}
std::vector<std::pair<std::string, std::string>> handlers_;
std::vector<std::pair<std::string, Response::ResponseCode>> requests_;
};
}
}
#endif // SERVER_STATS_H