Template
1
0

Added proper file reading

This commit is contained in:
2025-06-26 02:07:58 +03:00
parent ea8b8c884e
commit effa9ec9fa
3 changed files with 23 additions and 10 deletions

View File

@@ -1,6 +1,7 @@
#include "Helpers.hpp"
#include <fstream>
#include <sstream>
#include <string>
// Should add caching here
std::string Helpers::ReadFile(std::string Path) {
@@ -9,3 +10,13 @@ std::string Helpers::ReadFile(std::string Path) {
contents << file.rdbuf();
return contents.str();
}
std::string Helpers::GenerateResponse(std::string statusCode,
std::string contentType,
std::string content) {
std::stringstream output;
output << "HTTP/1.1 " << statusCode << "\n"
<< "Content-Type: " << contentType << "\nConnection: close\n\n"
<< content;
return output.str();
}