C and C++ web framework.
http://rapida.vilor.one/docs
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
1.5 KiB
68 lines
1.5 KiB
2 years ago
|
/* SPDX-License-Identifier: GPL-3.0-or-later */
|
||
|
/* Copyright 2022 Ivan Polyakov */
|
||
|
|
||
|
/*!
|
||
|
* \file app.h
|
||
|
* \brief Rapida application
|
||
|
*/
|
||
|
#ifndef RAPIDA_APP_H_ENTRY
|
||
|
#define RAPIDA_APP_H_ENTRY
|
||
|
|
||
|
#include "route.h"
|
||
|
|
||
|
#ifdef __cplusplus
|
||
|
extern "C" {
|
||
|
#endif
|
||
|
|
||
|
/*!
|
||
|
* \brief Rapida application main struct.
|
||
|
*/
|
||
|
typedef struct {
|
||
|
int running; /**< Application will be running while this flag is true. */
|
||
|
const char *sock_path; /**< Application UNIX Socket path. */
|
||
|
int sock_id; /**< Application UNIX Socket id. */
|
||
|
int routes_len; /**< Length of the rpd_app::routes array. */
|
||
|
rpd_route *routes; /**< Array of the active routes. */
|
||
|
} rpd_app;
|
||
|
|
||
|
/*!
|
||
|
* \brief Creates Rapida application.
|
||
|
*
|
||
|
* \param app Pointer to application instance.
|
||
|
* \param sock_path UNIX Socket path.
|
||
|
*
|
||
|
* \return Status. 0 is success.
|
||
|
*/
|
||
|
int rpd_app_create(rpd_app *app, const char *sock_path);
|
||
|
|
||
|
/*!
|
||
|
* \brief Starts Rapida main loop.
|
||
|
* \param app Application instance.
|
||
|
*
|
||
|
* \return Status. 0 is success.
|
||
|
*/
|
||
|
int rpd_app_start(rpd_app *app);
|
||
|
|
||
|
/*!
|
||
|
* \brief Adds route to application.
|
||
|
*
|
||
|
* It's better to add routes before application start,
|
||
|
* because rpd_app::routes when you add new route
|
||
|
* rpd_app::routes will be reallocated.
|
||
|
*
|
||
|
* \param app Application instance.
|
||
|
* \param path Path to handle.
|
||
|
* \param cb Handling callback.
|
||
|
* \param userdata Additional data to pass to cb.
|
||
|
*
|
||
|
* \return Status. 0 is success.
|
||
|
*/
|
||
|
int rpd_app_add_route(rpd_app *app, const char *path, rpd_route_cb cb,
|
||
|
void *userdata);
|
||
|
|
||
|
#ifdef __cplusplus
|
||
|
}
|
||
|
#endif
|
||
|
|
||
|
#endif // RAPIDA_APP_H_ENTRY
|