core-legacy/include/router.h

36 lines
687 B
C
Raw Permalink Normal View History

2020-05-05 09:42:02 +00:00
#ifndef CORE_ROUTER_H
#define CORE_ROUTER_H
#include <mongoose.h>
2020-05-30 22:23:57 +00:00
#include <endpoint.h>
2020-05-05 09:42:02 +00:00
2020-05-30 22:23:57 +00:00
#define ROUTER_ENDPOINTS_MAX_COUNT 128
2020-05-05 09:42:02 +00:00
typedef enum
{
HTTP_METHOD_GET = (1 << 0),
HTTP_METHOD_POST = (1 << 1),
HTTP_METHOD_PUT = (1 << 2),
HTTP_METHOD_DELETE = (1 << 3),
HTTP_METHOD_OPTIONS = (1 << 4),
HTTP_METHOD_WEBSOCKET = (1 << 5)
} http_method_e;
2020-06-02 22:47:49 +00:00
endpoint_t*
router_get_not_found_endpoint();
2020-05-05 09:42:02 +00:00
void
router_init();
endpoint_t*
router_register_endpoint(const char *route, int method, endpoint_func_f func);
2020-05-05 09:42:02 +00:00
endpoint_t*
router_find_endpoint(const char *uri_str, size_t uri_len, struct mg_str *method_str);
2020-05-05 09:42:02 +00:00
void
router_free();
#endif /* CORE_ROUTER_H */