First really working router Version

This commit is contained in:
Pablu23
2024-07-08 16:08:10 +02:00
parent 752cb229c3
commit 986be64e03
12 changed files with 424 additions and 73 deletions

26
router.hpp Normal file
View File

@@ -0,0 +1,26 @@
#ifndef ROUTER_H
#define ROUTER_H
#include "request.hpp"
#include "response.hpp"
#include <functional>
#include <map>
#include <netinet/in.h>
#include <string>
class Router {
private:
std::map<std::string, std::function<Response(Request, Response)>> m_routes;
int m_socket;
sockaddr_in m_address;
Response Route(Request req);
public:
Router(int port);
void Handle(std::string pathPattern,
std::function<Response(Request, Response)> func);
int Start();
int Stop();
};
#endif // !ROUTER_H