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.
|
|
|
#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");
|
|
|
|
}
|