Added proper file reading
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user