add: OPTIONS method support
add: relay tag endpoint
This commit is contained in:
parent
dab106c1f6
commit
420bdeb2aa
6 changed files with 158 additions and 26 deletions
include
|
@ -6,4 +6,7 @@
|
|||
void
|
||||
api_v1_relays_GET(struct mg_connection *c, endpoint_args_t *args, struct http_message *hm);
|
||||
|
||||
void
|
||||
api_v1_relays_tag_STR_GET(struct mg_connection *c, endpoint_args_t *args, struct http_message *hm);
|
||||
|
||||
#endif /* CORE_ENDPOINTS_API_V1_RELAYS_H */
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <mongoose.h>
|
||||
|
||||
#define ENDPOINTS_MAX_COUNT 16
|
||||
#define ENDPOINTS_MAX_COUNT 128
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
@ -11,6 +11,15 @@ typedef enum
|
|||
ENDPOINT_ARG_TYPE_STR
|
||||
} endpoint_arg_type_e;
|
||||
|
||||
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_e;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
endpoint_arg_type_e type;
|
||||
|
@ -25,10 +34,13 @@ typedef void (*endpoint_func_f)(struct mg_connection *c, endpoint_args_t *args,
|
|||
|
||||
typedef struct
|
||||
{
|
||||
const char *full_route;
|
||||
char **route;
|
||||
char *route_keeper;
|
||||
int methods;
|
||||
int method;
|
||||
int options;
|
||||
endpoint_func_f func;
|
||||
int trailing_slash;
|
||||
|
||||
int args_count;
|
||||
endpoint_args_t *args;
|
||||
|
@ -40,11 +52,11 @@ typedef struct
|
|||
void
|
||||
router_init();
|
||||
|
||||
void
|
||||
router_register_endpoint(const char *route, int methods, endpoint_func_f func);
|
||||
endpoint_t*
|
||||
router_register_endpoint(const char *route, int method, endpoint_func_f func);
|
||||
|
||||
endpoint_t*
|
||||
router_find_endpoint(const char *uri_str, size_t uri_len, struct mg_str *method);
|
||||
router_find_endpoint(const char *uri_str, size_t uri_len, struct mg_str *method_str);
|
||||
|
||||
void
|
||||
router_free();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue