0
0
Fork 0
wireless-proxy-esp32/project_components/web_server/web_uri_module.h

31 lines
884 B
C

#ifndef WEB_URI_MODULE_H_GUARD
#define WEB_URI_MODULE_H_GUARD
#include <esp_http_server.h>
typedef int (*uri_module_func)(const httpd_uri_t **uri);
typedef struct uri_module_t {
uri_module_func init;
uri_module_func exit;
uint8_t priority;
} uri_module_t;
/**
* @param priority smaller number will be called first
* @return 0: SUCCESS, 1: max module count reached
*/
int uri_module_add(uint8_t priority, uri_module_func init, uri_module_func exit);
/**
* @brief Register a uri module that will be init with PRI(priority) order.
* smaller priority will be called first.
*/
#define WEB_URI_MODULE_REGISTER(PRI, INIT, EXIT) \
__attribute__((used, constructor(PRI))) void cons_ ## INIT(); \
void cons_ ## INIT() { uri_module_add(PRI, INIT, EXIT); }
int uri_module_init(httpd_handle_t server);
int uri_module_exit(httpd_handle_t server);
#endif //WEB_URI_MODULE_H_GUARD