diff --git a/CMakeLists.txt b/CMakeLists.txt index 796e80a..96cbd94 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ set(sources src/main.cpp src/http/microhttpd_server.cpp src/http/request.cpp src/http/response.cpp + src/protocol/webfinger//webfinger.cpp src/config/config_http.cpp src/config/config_db.cpp src/config/config_loader.cpp diff --git a/src/http/httpserver.h b/src/http/httpserver.h index ea000ec..f5b1d29 100644 --- a/src/http/httpserver.h +++ b/src/http/httpserver.h @@ -57,7 +57,7 @@ namespace HTTP * map to a function */ void add_routes(std::initializer_list requests); - void add_route(RequestCallbackPair_t requests); + void add_route(RequestCallbackPair_t request); /** * @brief Handles a crafted HTTP Request diff --git a/src/main.cpp b/src/main.cpp index 8f2ea3e..6ae35c8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -26,6 +26,13 @@ #include "http/microhttpd_server.h" #include "logger.h" #include "route_args.h" +#include "protocol/webfinger/webfinger.h" + +void init_routes(const std::unique_ptr& server) +{ + Protocol::Webfinger::init_webfinger(server.get()); + +} int start_wormhole() { @@ -70,6 +77,8 @@ int start_wormhole() database->try_migration(); + init_routes(server); + // TODO Move to another file server->add_routes({ { {HTTP::Request::Type::GET, "/"}, [](std::any& args, const HTTP::RequestArgs_t& arg){ diff --git a/src/protocol/webfinger/webfinger.cpp b/src/protocol/webfinger/webfinger.cpp index 5f43651..c8698e6 100644 --- a/src/protocol/webfinger/webfinger.cpp +++ b/src/protocol/webfinger/webfinger.cpp @@ -16,11 +16,20 @@ * along with this program. If not, see . */ +#include +#include "http/response.h" #include "webfinger.h" +#include "http/httpserver.h" +#include "http/request.h" using namespace Protocol; -void init_webfinger() +HTTP::Response Route::webfinger(std::any& args, const HTTP::RequestArgs_t& arg) { } + +void Webfinger::init_webfinger(HTTP::Server* server) +{ + server->add_route({{HTTP::Request::Type::GET, "/.well-known/webfinger"}, Route::webfinger}); +} diff --git a/src/protocol/webfinger/webfinger.h b/src/protocol/webfinger/webfinger.h index 5f7229c..1f1dd99 100644 --- a/src/protocol/webfinger/webfinger.h +++ b/src/protocol/webfinger/webfinger.h @@ -18,10 +18,18 @@ #pragma once +#include "http/httpserver.h" +#include "http/response.h" + +namespace Route +{ + HTTP::Response webfinger(std::any& args, const HTTP::RequestArgs_t& arg); +} + namespace Protocol { namespace Webfinger { - + void init_webfinger(HTTP::Server* server); } }