feat: routes now specify a method
This commit is contained in:
parent
9b66223a57
commit
18d67fb69f
8 changed files with 40 additions and 17 deletions
|
|
@ -11,11 +11,11 @@
|
|||
extern const char *http_response_type_names[5][32];
|
||||
|
||||
typedef enum http_request_method {
|
||||
http_request_method_get = 0,
|
||||
http_request_method_post = 1,
|
||||
http_request_method_put = 2,
|
||||
http_request_method_patch = 3,
|
||||
http_request_method_delete = 4
|
||||
http_get = 0,
|
||||
http_post = 1,
|
||||
http_put = 2,
|
||||
http_patch = 3,
|
||||
http_delete = 4
|
||||
} http_request_method;
|
||||
|
||||
extern const char *request_method_names[];
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ typedef enum http_route_type {
|
|||
|
||||
typedef struct http_route {
|
||||
http_route_type type;
|
||||
http_request_method method;
|
||||
char *path;
|
||||
regex_t *regex;
|
||||
bool (*steps[5])(event_loop_conn *);
|
||||
|
|
@ -93,7 +94,8 @@ void http_loop_process_request(event_loop_conn *conn);
|
|||
* Set the request body to the given buffer. If owned is set to true, the body
|
||||
* buffer will be free'd after the request has finished.
|
||||
*/
|
||||
void http_loop_res_set_body(const char *body, size_t body_len, bool owned);
|
||||
void http_loop_res_set_body(http_loop_ctx *ctx, const char *body,
|
||||
size_t body_len, bool owned);
|
||||
|
||||
/**
|
||||
* Initialize a new http loop
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue