Add method and route factory.

This commit is contained in:
Pol Henarejos
2026-04-12 12:09:44 +02:00
parent f84b6bed93
commit 7b8d09550a
2 changed files with 129 additions and 102 deletions

View File

@@ -2,6 +2,40 @@
#define PICO_KEYS_REST_SERVER_H
#include "lwip/err.h"
#include <stddef.h>
#include <stdint.h>
typedef enum {
REST_HTTP_GET = 0,
REST_HTTP_POST,
REST_HTTP_PUT,
REST_HTTP_DELETE
} rest_http_method_t;
typedef struct {
rest_http_method_t method;
const char *path;
const char *body;
size_t body_len;
const char *content_type;
} rest_request_t;
typedef struct {
uint16_t status_code;
const char *content_type;
const char *body;
size_t body_len;
} rest_response_t;
typedef int (*rest_route_handler_t)(const rest_request_t *request, rest_response_t *response);
typedef struct {
rest_http_method_t method;
const char *path;
rest_route_handler_t handler;
} rest_route_t;
const rest_route_t *rest_get_routes(size_t *count);
err_t rest_server_init(void);