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.
60 lines
1.1 KiB
60 lines
1.1 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 a Rapida application instance. |
|
* \brief Default constructor |
|
*/ |
|
App() |
|
{ |
|
rpd_app_create(&app); |
|
} |
|
|
|
/*! |
|
* \brief Returns C implementation of the application. |
|
* |
|
* Usable when you need to start C server. |
|
* |
|
* \return C implementation of the application. |
|
*/ |
|
rpd_app *c_app() const |
|
{ |
|
return (rpd_app *) &app; |
|
} |
|
|
|
/*! |
|
* \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
|
|
|