This project was build using the Boost Library. Please refer to License doc.
Download Boost library here: https://www.boost.org/users/download/
This project was designed for linux systems. However, the project should work fine on Windows. The compile script might not be the same as what is listed below.
Download Boost library here: https://www.boost.org/users/download/
#include "Router.h"
std::string& Router::Get(const HttpRequest& Request, std::stack<std::string>& CookieStack){
//Return a Path to a local html file. Return an empty string for invalid URL.
}
std::string& Router::Post(const HttpRequest& Request){
//Currently does nothing.
}
do Request.target().to_string() to get a String representation of the URL.
Refer to the Boost doccumentation for all other methods for the Request Object.
Both methods must be defined for the server to work!
#include "HttpServerBuilder.h"
#include "Router.cpp"
int main(int argc, char *argv[])
{
//WARNING, You are responsible for inputting command line arguments and checking their validity!
//Create our defined router
Router MyRouter;
//Reference ServerStartDetails.h for Argument Params
ServerStartDetails SSD(argv);
//Pass our router and server settings to the server builder
ServerBuilder Server(MyRouter, SSD);
//Start the server!
Server.Start();
return 0;
}
g++ Server.cpp -o Server -lboost_thread -lpthread
Do not forget to include the path to your Boost directory.
Usage: IP PORT ROOTDIR WORKERS spin|block
./Server 0.0.0.0 3000 . 100 block
Use curl to perform a get request.
curl localhost:3000
Use the included build scripts to deploy the working example
Refer to the License agreement before distributing or using