PsychichHTTP v2-dev

This commit is contained in:
iranl
2024-12-30 14:37:09 +01:00
parent 2cf5201285
commit 78459c2d08
118 changed files with 5453 additions and 4972 deletions

View File

@@ -4,6 +4,7 @@
#include "PsychicCore.h"
class PsychicHandler;
class PsychicMiddleware;
#ifdef ENABLE_ASYNC
#include "async_worker.h"
@@ -11,27 +12,39 @@ class PsychicHandler;
class PsychicEndpoint
{
friend PsychicHttpServer;
friend PsychicHttpServer;
private:
PsychicHttpServer *_server;
PsychicHttpServer* _server;
String _uri;
http_method _method;
PsychicHandler *_handler;
int _method;
PsychicHandler* _handler;
httpd_uri_match_func_t _uri_match_fn = nullptr; // use this change the endpoint matching function.
public:
PsychicEndpoint();
PsychicEndpoint(PsychicHttpServer *server, http_method method, const char * uri);
PsychicEndpoint(PsychicHttpServer* server, int method, const char* uri);
PsychicEndpoint *setHandler(PsychicHandler *handler);
PsychicHandler *handler();
PsychicEndpoint* setHandler(PsychicHandler* handler);
PsychicHandler* handler();
PsychicEndpoint* setFilter(PsychicRequestFilterFunction fn);
PsychicEndpoint* setAuthentication(const char *username, const char *password, HTTPAuthMethod method = BASIC_AUTH, const char *realm = "", const char *authFailMsg = "");
httpd_uri_match_func_t getURIMatchFunction();
void setURIMatchFunction(httpd_uri_match_func_t match_fn);
bool matches(const char* uri);
// called to process this endpoint with its middleware chain
esp_err_t process(PsychicRequest* request);
PsychicEndpoint* addFilter(PsychicRequestFilterFunction fn);
PsychicEndpoint* addMiddleware(PsychicMiddleware* middleware);
PsychicEndpoint* addMiddleware(PsychicMiddlewareCallback fn);
void removeMiddleware(PsychicMiddleware* middleware);
String uri();
static esp_err_t requestCallback(httpd_req_t *req);
static esp_err_t requestCallback(httpd_req_t* req);
};
#endif // PsychicEndpoint_h