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.

65 lines
1.4 KiB

/* 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. */
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.
*
* \return Status. 0 is success.
*/
int rpd_app_create(rpd_app *app);
/*!
* Handle accepted request.
* \param app Application instance.
2 years ago
* \param req Request.
* \param res Response.
*/
void rpd_app_handle_request(rpd_app *app, rpd_req *req, rpd_res *res);
/*!
* \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