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.
 
 
 

43 lines
901 B

#include "../../include/rapida.hxx"
#include "../../include/servers/fcgi.h"
/*
* \brief Home page route handler.
*/
class Home : public rpd::Route {
protected:
/*
* \brief Handle GET request.
*
* \param req Request.
* \param res Response.
*/
virtual void handle_get(const rpd::Request &req, rpd::Response &res) override
{
handle_head(req, res);
/* Unlike the C interface,
* the C++ wrapper will call `strdup` for you
*/
res.body("Hello World!");
}
/*
* \brief Handle HEAD request.
*/
virtual void handle_head(const rpd::Request &req, rpd::Response &res) override
{
res.status(rpd_res_st_ok);
res.content_type("text/plain");
}
};
int main()
{
rpd::App app;
app.add_route("/", new Home());
return rpd_fcgi_server_start(app.c_app(), "/tmp/webapp.socket");
}