Commit b2c5027a authored by James Allenby's avatar James Allenby
Browse files

Finished main project

parent 676602e9
......@@ -2,4 +2,5 @@ cmake_minimum_required(VERSION 2.8)
project(JAMP)
set(CMAKE_CXX_STANDARD "17")
add_executable(${PROJECT_NAME} "main.cc" "jampserver.cc" "httpresponse.cc" "httprequest.cc")
add_executable(${PROJECT_NAME}Server "main.cc" "jampserver.cc" "httpresponse.cc" "httprequest.cc")
add_library(${PROJECT_NAME} "jampserver.cc" "httpresponse.cc" "httprequest.cc")
#include <fstream>
#include "jampserver.hh"
std::string get_file_contents(const char *filename)
{
std::ifstream in(filename, std::ios::in | std::ios::binary);
if (in)
{
std::string contents;
in.seekg(0, std::ios::end);
contents.resize(in.tellg());
in.seekg(0, std::ios::beg);
in.read(&contents[0], contents.size());
in.close();
return(contents);
}
throw(errno);
}
int main()
{
std::string file = get_file_contents("rules.ninja");
JAMP::Server server;
server.All("/", [](auto& request, auto& response)
{
server.All("/", [](auto& request, auto& response) {
response.SetResponseCode(JAMP::Code::HTTP_200);
response.Write("hello");
response.Close();
});
server.All("/a", [](auto& request, auto& response)
{
server.All("/rules", [file](auto& request, auto& response) {
response.SetResponseCode(JAMP::Code::HTTP_200);
response.Write("helloworld");
response.Write(file);
response.Close();
});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment