Morse Micro IoT SDK  2.10.4
restfs.h
1/*
2 * Copyright 2022-2023 Morse Micro
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6#pragma once
7
8#include <stdint.h>
9
10#if !defined(LWIP_HTTPD_CUSTOM_FILES)
11#error "http_rest requires LWIP HTTPD custom files"
12#endif
13
18struct restfs_file;
19
23typedef void (*rest_endpoint_handler_t)(struct restfs_file *);
24
29{
31 char *uri;
33 rest_endpoint_handler_t user_function;
34};
35
46int restfs_alloc_buffer(struct restfs_file *rest_file, uint16_t size);
47
59void restfs_write_const(struct restfs_file *rest_file, const char *str);
60
69int restfs_write(struct restfs_file *rest_file, const uint8_t *buff, uint16_t len);
70
79int restfs_printf(struct restfs_file *rest_file, const char *fmt, ...);
80
91char *restfs_claim_raw_buffer(struct restfs_file *rest_file);
92
99void restfs_release_raw_buffer(struct restfs_file *rest_file, uint16_t wr_len);
100
107void rest_init_endpoints(const struct rest_endpoint *endpoints, uint16_t num_endpoints);
A REST endpoint.
Definition: restfs.h:29
rest_endpoint_handler_t user_function
User defined function to call when this endpoint is requested by a client.
Definition: restfs.h:33
char * uri
URI of endpoint.
Definition: restfs.h:31
Opaque object used for writing REST output data.
Definition: restfs.c:21