Add initial webserver sources

This commit is contained in:
2022-06-30 01:35:02 +02:00
parent 2721be2d22
commit 7b93dfa6cf
26 changed files with 1018 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
#include "examplewebserver.h"
#include "rootresponsehandler.h"
#include "debugresponsehandler.h"
#include "errorresponsehandler.h"
std::unique_ptr<ResponseHandler> ExampleWebserver::makeResponseHandler(ClientConnection &clientConnection, std::string_view method, std::string_view path, std::string_view protocol)
{
const std::string_view processedPath{[&](){
const auto index = path.find('?');
return index == std::string_view::npos ?
path : path.substr(0, index);
}()};
if (processedPath.empty() || processedPath == "/")
return std::make_unique<RootResponseHandler>(clientConnection);
else if (processedPath == "/debug" || processedPath.starts_with("/debug/") )
return std::make_unique<DebugResponseHandler>(clientConnection, method, path, protocol);
else
return std::make_unique<ErrorResponseHandler>(clientConnection, path);
}