# Ulfius HTTP Framework
![.github/workflows/ccpp.yml](https://github.com/babelouest/ulfius/workflows/.github/workflows/ccpp.yml/badge.svg)
![CodeQL](https://github.com/babelouest/ulfius/workflows/CodeQL/badge.svg)
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/3195/badge)](https://bestpractices.coreinfrastructure.org/projects/3195)
HTTP Framework for REST Applications in C.
Based on [GNU Libmicrohttpd](https://www.gnu.org/software/libmicrohttpd/) for the backend web server, [Jansson](http://www.digip.org/jansson/) for the json manipulation library, and [Libcurl](http://curl.haxx.se/libcurl/) for the http/smtp client API.
Used to facilitate creation of web applications in C programs with a small memory footprint, as in embedded systems applications.
You can create webservices in HTTP or HTTPS mode, stream data, or implement server websockets.
## Hello World! example application
The source code of a hello world using Ulfius is the following:
```C
/**
* test.c
* Small Hello World! example
* to compile with gcc, run the following command
* gcc -o test test.c -lulfius
*/
#include <stdio.h>
#include <ulfius.h>
#define PORT 8080
/**
* Callback function for the web application on /helloworld url call
*/
int callback_hello_world (const struct _u_request * request, struct _u_response * response, void * user_data) {
ulfius_set_string_body_response(response, 200, "Hello World!");
return U_CALLBACK_CONTINUE;
}
/**
* main function
*/
int main(void) {
struct _u_instance instance;
// Initialize instance with the port number
if (ulfius_init_instance(&instance, PORT, NULL, NULL) != U_OK) {
fprintf(stderr, "Error ulfius_init_instance, abort\n");
return(1);
}
// Endpoint list declaration
ulfius_add_endpoint_by_val(&instance, "GET", "/helloworld", NULL, 0, &callback_hello_world, NULL);
// Start the framework
if (ulfius_start_framework(&instance) == U_OK) {
printf("Start framework on port %d\n", instance.port);
// Wait for the user to press <enter> on the console to quit the application
getchar();
} else {
fprintf(stderr, "Error starting framework\n");
}
printf("End framework\n");
ulfius_stop_framework(&instance);
ulfius_clean_instance(&instance);
return 0;
}
```
## Main features
### Webservice
- Create a webservice in a separate thread, the endpoint is identified by its method (ex: `GET`, `POST`, `PUT`, `DELETE`, etc.) and its URL path with its optional parameters (ex: `/api/doc/@id`). The webservice is executed in a callback function.
- Stream large amount of data with a reduced memory footprint.
- Websocket service, the websocket messages exchange is executed in dedicated callback functions.
### Client requests
- Client http[s] and smtp requests execution, the response is parsed in a dedicated structure.
- Client websocket request execution, the websocket messages exchange is executed in dedicated callback functions.
### Websockets
- Create a websocket service application
- Create websocket client application
- CLI to connect to a remote websocket: [uwsc](https://github.com/babelouest/ulfius/tree/master/tools/uwsc)
## Installation
See [INSTALL.md](INSTALL.md) file for installation details
## Documentation
See [API.md](API.md) file for API documentation details
See the [online documentation](https://babelouest.github.io/ulfius/) for a doxygen format of the API documentation.
## Example programs source code
Example programs are available to understand the different functionalities available, see [example_programs](https://github.com/babelouest/ulfius/blob/master/example_programs) folder for detailed sample source codes and documentation.
## Example callback functions
Example callback functions are available in the folder [example_callbacks](https://github.com/babelouest/ulfius/blob/master/example_callbacks). The example callback functions available are:
- static file server: to provide static files of a specific folder
- oauth2 bearer: to check the validity of a Oauth2 bearer jwt token. Requires [libjwt](https://github.com/benmcollins/libjwt).
## Projects using Ulfius framework
- [Glewlwyd](https://github.com/babelouest/glewlwyd), a lightweight SSO server that provides OAuth2 and OpenID Connect authentication protocols
- [Le Biniou](https://biniou.net/), user-friendly yet powerful music visualization / VJing tool
- [Angharad](https://github.com/babelouest/angharad), House automation system for ZWave and other types of devices
- [Hutch](https://github.com/babelouest/hutch), a safe locker for passwords and other secrets, using JavaScript client side encryption only
- [Taliesin](https://github.com/babelouest/taliesin), a lightweight audio streaming server
- [Taulas Raspberry Pi Serial interface](https://github.com/babelouest/taulas/tree/master/taulas_raspberrypi_serial), an interface for Arduino devices that implement [Taulas](https://github.com/babelouest/taulas/) protocol, a house automation protocol for Angharad
## Questions, problems ?
I'm open for questions and suggestions, feel free to open an [issue](https://github.com/babelouest/ulfius/issues), a [pull request](https://github.com/babelouest/ulfius/pulls) or send me an [e-mail](mailto:mail@babelouest.io) if you feel like it!
You can visit the IRC channel #ulfius on the [Libera.Chat](https://libera.chat/) network.
没有合适的资源?快使用搜索试试~ 我知道了~
嵌入式Freertos Rest API 源代码,移植自ulfius,
共631个文件
c:234个
h:83个
m4:35个
需积分: 5 1 下载量 199 浏览量
2023-09-25
22:39:43
上传
评论
收藏 2.78MB RAR 举报
温馨提示
嵌入式Freertos Rest API 源代码,移植自ulfius, libmicrohttpd, orcania, 通过修改源代码使得这三个开源库可以应用在嵌入式操作系统Freertos, 运行在单片机MCU上。
资源推荐
资源详情
资源评论
收起资源包目录
嵌入式Freertos Rest API 源代码,移植自ulfius, (631个子文件)
uwsc.1 2KB
base64url.1 1KB
libmicrohttpd.3 1KB
ABOUT-NLS 92KB
configure.ac 111KB
Makefile.am 14KB
Makefile.am 10KB
Makefile.am 6KB
Makefile.am 6KB
Makefile.am 3KB
Makefile.am 2KB
Makefile.am 2KB
Makefile.am 2KB
Makefile.am 1KB
Makefile.am 878B
Makefile.am 452B
Makefile.am 379B
Makefile.am 254B
Makefile.am 96B
Makefile.am 67B
ascebc 146B
AUTHORS 3KB
framework.c 811KB
test_websocket.c 383KB
daemon.c 257KB
connection.c 173KB
test_str.c 156KB
example_callbacks.c 150KB
u_websocket.c 128KB
connection_call_handlers.c 120KB
ulfius.c 86KB
websocket_chatserver_example.c 80KB
mhd_websocket.c 80KB
test_upgrade_large.c 68KB
core.c 68KB
response.c 63KB
websocket.c 62KB
test_client_put_stop.c 62KB
test_toolarge.c 53KB
mhd_send.c 53KB
digestauth.c 46KB
postprocessor.c 41KB
u_request.c 39KB
mhd_str.c 37KB
u_send_request.c 37KB
test_upgrade.c 36KB
test_add_conn.c 36KB
str_test.c 35KB
connection_add.c 35KB
test_tricky.c 35KB
test_postprocessor_md.c 34KB
test_get_close_keep_alive.c 34KB
demo_https.c 31KB
u_response.c 29KB
test_get.c 29KB
daemon_start.c 29KB
test_large_put.c 27KB
demo.c 27KB
test_postprocessor.c 27KB
test_response_entries.c 26KB
daemon_select.c 26KB
mhd_sockets.c 24KB
websocket_threaded_example.c 24KB
test_post.c 23KB
daemon_options.c 23KB
static_compressed_inmemory_website_callback.c 22KB
test_get_chunked.c 21KB
post_example.c 21KB
sessions.c 21KB
test_get_iovec.c 20KB
mhd_str.c 20KB
test_post_loop.c 19KB
perf_get.c 19KB
sha256.c 18KB
oidc_resource.c 17KB
test_get_sendfile.c 17KB
test_sha256.c 17KB
test_postform.c 17KB
tls_test_common.c 17KB
daemon_epoll.c 17KB
memorypool.c 16KB
orcania.c 16KB
uwsc.c 16KB
test_sha1.c 16KB
test_process_headers.c 16KB
test_delete.c 16KB
test_put_chunked.c 16KB
sha1.c 16KB
sha1.c 16KB
test_put.c 15KB
test_quiesce.c 15KB
daemon_poll.c 15KB
test_md5.c 15KB
mhd_sockets.c 15KB
perf_get_concurrent.c 14KB
mhd_mono_clock.c 14KB
u_map.c 14KB
upgrade_process.c 14KB
test_str_tokens_remove.c 14KB
websocket_server.c 13KB
共 631 条
- 1
- 2
- 3
- 4
- 5
- 6
- 7
资源评论
水耗子
- 粉丝: 45
- 资源: 12
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- MyBatis 动态 SQL:灵活而强大的查询构建器.pdf
- com.accordion.prettyo.apk
- 毕业设计:基于SSM的mysql-ssm软件bug管理系统(源码 + 数据库 + 说明文档)
- MTSQL8.0.35windows(64bit)-mysql-installer-community-8.0.35.0
- 人工智能引领音乐创作新时代之Suno AI
- Public-bicycle-usage-forecast-master.zip
- 通道处理过程模拟:从理论到实践.pdf
- 数据库第七次作业E-R图第一题
- 大厂面试真题Java语法基础面试专题及答案
- IMG20240428211124.jpg
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功