Morse Micro IoT SDK  2.9.7
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
30 char* uri;
32 rest_endpoint_handler_t user_function;
33};
34
45int restfs_alloc_buffer(struct restfs_file *rest_file, uint16_t size);
46
58void restfs_write_const(struct restfs_file *rest_file, const char* str);
59
68int restfs_write(struct restfs_file *rest_file, const uint8_t *buff, uint16_t len);
69
78int restfs_printf(struct restfs_file *rest_file, const char *fmt, ...);
79
90char* restfs_claim_raw_buffer(struct restfs_file *rest_file);
91
98void restfs_release_raw_buffer(struct restfs_file *rest_file, uint16_t wr_len);
99
100
107void rest_init_endpoints(const struct rest_endpoint* endpoints, uint16_t num_endpoints);
A REST endpoint.
Definition: restfs.h:28
rest_endpoint_handler_t user_function
User defined function to call when this endpoint is requested by a client.
Definition: restfs.h:32
char * uri
URI of endpoint.
Definition: restfs.h:30
Opaque object used for writing REST output data.
Definition: restfs.c:20