-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathressource.cpp
More file actions
29 lines (27 loc) · 786 Bytes
/
Copy pathressource.cpp
File metadata and controls
29 lines (27 loc) · 786 Bytes
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
#include "ressource.hpp"
using namespace std;
StaticRessource::StaticRessource(const std::string &path){
cacheable = true;
ifstream file(path);
std::string str((std::istreambuf_iterator<char>(file)),
std::istreambuf_iterator<char>());
content.assign(str);
file.close();
}
Response * StaticRessource::buildResp(Request&){
auto header = std::map<std::string, std::string>();
header["Content-Type"] = MIME;
return new OK(content, header);
}
EchoRessource::EchoRessource(){
cacheable = false;
};
Response * EchoRessource::buildResp(Request& req){
if (req.method != POST){
return new BadRequest();
}
else {
auto header = std::map<std::string, std::string>();
return new OK(req.body, header);
}
}