-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathResponse.h
47 lines (35 loc) · 1.22 KB
/
Response.h
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
#pragma once
#include "Message.h"
namespace shitty {
class Response {
public:
// Most constructors allow implicit conversions on purpose
explicit Response(unsigned status_code = 200, std::string&& body = std::string());
Response(std::string&& body);
Response(std::initializer_list<std::string> headers, std::string&& body);
Response(std::initializer_list<Header> headers, std::string&& body);
Response(unsigned status_code, Message&& msg);
Message message;
Headers& headers() { return message.headers(); }
const Headers& headers() const { return message.headers(); }
std::string& body() { return message.body(); }
const std::string& body() const { return message.body(); }
inline unsigned statusCode() const;
inline void setStatusCode(unsigned status_code);
private:
unsigned status_code_ = 200;
};
inline Response::Response(std::string&& body):
message(std::move(body))
{}
inline Response::Response(unsigned status_code, std::string&& body):
message(std::move(body)),
status_code_(status_code)
{}
inline unsigned Response::statusCode() const {
return status_code_;
}
inline void Response::setStatusCode(unsigned status_code) {
status_code_ = status_code;
}
}