43 lines
789 B
C++
43 lines
789 B
C++
// SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
#include <array>
|
|
#include <string_view>
|
|
|
|
#include <nlohmann/json.hpp>
|
|
|
|
#include "request/request.h"
|
|
#include "stream/ostream.h"
|
|
|
|
class Response {
|
|
public:
|
|
enum class Status {
|
|
ok,
|
|
notFound,
|
|
methodNotAllowed,
|
|
internalError,
|
|
__size
|
|
};
|
|
|
|
enum class ContentType {
|
|
text,
|
|
json,
|
|
__size
|
|
};
|
|
Response(Request& request);
|
|
Response(Request& request, Status status);
|
|
|
|
void send() const;
|
|
void setBody(const std::string& body);
|
|
void setBody(const nlohmann::json& body);
|
|
|
|
private:
|
|
Request& request;
|
|
Status status;
|
|
ContentType type;
|
|
std::string body;
|
|
};
|