birdbadge/src/response.cpp

43 lines
1022 B
C++

#include "response.h"
constexpr static const char* pathDelimiter("/");
Response::Response(const std::string_view& path):
status(Status::ok),
body()
{
std::vector<std::string_view> split = splitPath(path);
selfIndentification(split);
}
void Response::selfIndentification(const std::vector<std::string_view>& path) {
if (path.size() == 0) {
status = Status::ok;
}
}
void Response::writeHeader(std::ostream& out) const {
}
void Response::writeBody(std::ostream& out) const {
}
std::vector<std::string_view> Response::splitPath(std::string_view path) {
std::vector<std::string_view> output;
std::string_view::size_type first = 0;
while (first < path.size()) {
const std::string_view::size_type second = path.find_first_of(pathDelimiter, first);
if (first != second)
output.emplace_back(path.substr(first, second - first));
if (second == std::string_view::npos)
break;
first = second + 1;
}
return output;
}