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.2 KiB
65 lines
1.2 KiB
/* SPDX-License-Identifier: GPL-3.0-or-later */ |
|
/* Copyright 2022 Ivan Polyakov */ |
|
|
|
#ifndef RAPIDA_APP_HXX_ENTRY |
|
#define RAPIDA_APP_HXX_ENTRY |
|
|
|
#include "Request.hxx" |
|
#include "Response.hxx" |
|
#include "Route.hxx" |
|
#include "app.h" |
|
|
|
namespace rpd { |
|
/*! |
|
* \brief C++ wrapper for Rapida application. |
|
*/ |
|
class App { |
|
public: |
|
/*! |
|
* Creates an rpd app and initializes FastCGI. |
|
* \brief Constructor |
|
* \param socket_path UNIX Socket path. |
|
*/ |
|
App(const char *const socket_path) |
|
{ |
|
rpd_app_create(&app, socket_path); |
|
} |
|
|
|
/*! |
|
* \brief Starts the requests handling loop. |
|
*/ |
|
int start() |
|
{ |
|
return rpd_app_start(&app); |
|
} |
|
|
|
/*! |
|
* \brief Stops the requests handling loop. |
|
*/ |
|
void stop() |
|
{ |
|
app.running = false; |
|
} |
|
|
|
/*! |
|
* \brief Adds handler for the path. |
|
* |
|
* \param path Enpoint. |
|
* \param route Route handler. |
|
*/ |
|
void add_route(const char *const path, Route *route) |
|
{ |
|
rpd_app_add_route(&app, path, &Route::handle_request, route); |
|
} |
|
|
|
/*! |
|
* \brief Destructor. |
|
*/ |
|
virtual ~App() { } |
|
|
|
private: |
|
rpd_app app; //< Composition with C implementation. |
|
}; |
|
} |
|
|
|
#endif // RAPIDA_APP_HXX_ENTRY
|
|
|