pica/response/response.h

39 lines
644 B
C
Raw Normal View History

2023-11-21 22:19:08 +00:00
#pragma once
#include <string>
#include <array>
#include <string_view>
2023-11-23 19:57:32 +00:00
#include <nlohmann/json.hpp>
2023-11-21 22:19:08 +00:00
#include "request/request.h"
#include "stream/ostream.h"
class Response {
public:
enum class Status {
ok,
notFound,
methodNotAllowed,
internalError,
__size
};
enum class ContentType {
text,
2023-11-23 19:57:32 +00:00
json,
2023-11-21 22:19:08 +00:00
__size
};
Response();
Response(Status status);
void replyTo(Request& request) const;
void setBody(const std::string& body);
2023-11-23 19:57:32 +00:00
void setBody(const nlohmann::json& body);
2023-11-21 22:19:08 +00:00
private:
Status status;
ContentType type;
std::string body;
};