All Projects → babelouest → Ulfius

babelouest / Ulfius

Licence: lgpl-2.1
Web Framework to build REST APIs, Webservices or any HTTP endpoint in C language. Can stream large amount of data, integrate JSON data with Jansson, and create websocket services

Programming Languages

c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to Ulfius

Websocat
Command-line client for WebSockets, like netcat (or curl) for ws:// with advanced socat-like functions
Stars: ✭ 3,477 (+422.07%)
Mutual labels:  websockets, websocket-server, websocket-client
Http Prompt
An interactive command-line HTTP and API testing client built on top of HTTPie featuring autocomplete, syntax highlighting, and more. https://twitter.com/httpie
Stars: ✭ 8,329 (+1150.6%)
Mutual labels:  rest-api, json, web-development
Facil.io
Your high performance web application C framework
Stars: ✭ 1,393 (+109.16%)
Mutual labels:  json, websockets, websocket-server
Arduinowebsockets
arduinoWebSockets
Stars: ✭ 1,265 (+89.94%)
Mutual labels:  websockets, websocket-server, websocket-client
reactive-streams-for-java-developers
No description or website provided.
Stars: ✭ 16 (-97.6%)
Mutual labels:  websocket-server, websockets, websocket-client
Php Wss
Web-socket server/client with multi-process and parse templates support on server and send/receive options on client
Stars: ✭ 117 (-82.43%)
Mutual labels:  websockets, websocket-server, websocket-client
Generator Http Fake Backend
Yeoman generator for building a fake backend by providing the content of JSON files or JavaScript objects through configurable routes.
Stars: ✭ 49 (-92.64%)
Mutual labels:  rest-api, restful, json
Wok
A cherrypy framework for multi-purpose plug-ins
Stars: ✭ 215 (-67.72%)
Mutual labels:  restful, webservice, websockets
text
An experiment with WebSockets and the human condition.
Stars: ✭ 51 (-92.34%)
Mutual labels:  websocket-server, websockets, websocket-client
remoting
Jetlang Remoting - asynchronous distributed messaging
Stars: ✭ 27 (-95.95%)
Mutual labels:  websocket-server, websockets, websocket-client
Stl.fusion
Get real-time UI updates in Blazor apps and 10-1000x faster API responses with a novel approach to distributed reactive computing. Fusion brings computed observables and automatic dependency tracking from Knockout.js/MobX/Vue to the next level by enabling a single dependency graph span multiple servers and clients, including Blazor apps running in browser.
Stars: ✭ 858 (+28.83%)
Mutual labels:  websockets, websocket-server, websocket-client
Beast
HTTP and WebSocket built on Boost.Asio in C++11
Stars: ✭ 3,241 (+386.64%)
Mutual labels:  websockets, websocket-server, websocket-client
Awesome Websockets
A curated list of Websocket libraries and resources.
Stars: ✭ 850 (+27.63%)
Mutual labels:  websockets, websocket-server, websocket-client
Ixwebsocket
websocket and http client and server library, coming with ws, a command line swiss army knife utility
Stars: ✭ 204 (-69.37%)
Mutual labels:  websockets, websocket-server, websocket-client
Http Fake Backend
Build a fake backend by providing the content of JSON files or JavaScript objects through configurable routes.
Stars: ✭ 253 (-62.01%)
Mutual labels:  rest-api, restful, json
LazWebsockets
Websocket Server and Client Library written in Lazarus
Stars: ✭ 51 (-92.34%)
Mutual labels:  websocket-server, websockets, websocket-client
Websockets
Library for building WebSocket servers and clients in Python
Stars: ✭ 3,724 (+459.16%)
Mutual labels:  websockets, websocket-server, websocket-client
Rest Api Design Guide
NBB's REST-ish API Design Guide
Stars: ✭ 643 (-3.45%)
Mutual labels:  rest-api, restful
Websocket
The Hoa\Websocket library.
Stars: ✭ 421 (-36.79%)
Mutual labels:  websocket-server, websocket-client
Laravel Api Response Builder
Builds nice, normalized and easy to consume Laravel REST API JSON responses.
Stars: ✭ 433 (-34.98%)
Mutual labels:  rest-api, json

Ulfius HTTP Framework

.github/workflows/ccpp.yml CodeQL CII Best Practices

HTTP Framework for REST Applications in C.

Based on GNU Libmicrohttpd for the backend web server, Jansson for the json manipulation library, and 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:

/**
 * 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

Installation

See INSTALL.md file for installation details

Documentation

See API.md file for API documentation details

See the online documentation 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 folder for detailed sample source codes and documentation.

Example callback functions

Example callback functions are available in the folder 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.

Projects using Ulfius framework

  • Glewlwyd, a lightweight SSO server that provides OAuth2 and OpenID Connect authentication protocols
  • Le Biniou, user-friendly yet powerful music visualization / VJing tool
  • Angharad, House automation system for ZWave and other types of devices
  • Hutch, a safe locker for passwords and other secrets, using JavaScript client side encryption only
  • Taliesin, a lightweight audio streaming server
  • Taulas Raspberry Pi Serial interface, an interface for Arduino devices that implement Taulas protocol, a house automation protocol for Angharad

Questions, problems ?

I'm open for questions and suggestions, feel free to open an issue, a pull request or send me an e-mail if you feel like it!

You can visit the IRC channel #ulfius on the Freenode network.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].