-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathserver_stats.cpp
More file actions
49 lines (38 loc) · 1.4 KB
/
server_stats.cpp
File metadata and controls
49 lines (38 loc) · 1.4 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "server_stats.hpp"
namespace http {
namespace server {
ServerStats& ServerStats::getInstance() {
static ServerStats instance;
return instance;
}
void ServerStats::insertHandler(const std::string& prefix, const std::string& handler_name) {
std::pair<std::string, std::string> handler(prefix, handler_name);
//Checks to see that no duplicate entries are being added
for (unsigned int i=0; i < handlers_.size(); i++)
{
if (handlers_[i].first == prefix)
{
return;
}
}
handlers_.push_back(handler);
}
void ServerStats::insertRequest(const std::string& url, Response::ResponseCode response) {
std::pair<std::string, Response::ResponseCode> req(url, response);
requests_.push_back(req);
}
int ServerStats::getNumRequests() {
return requests_.size();
}
void ServerStats::clearAllEntries() {
handlers_.clear();
requests_.clear();
}
std::vector<std::pair<std::string, std::string>> ServerStats::getHandlers() const {
return handlers_;
}
std::vector<std::pair<std::string, Response::ResponseCode>> ServerStats::getRequests() const {
return requests_;
}
}
}