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.

44 lines
0 B

#include "../../include/rapida.hxx"
2 years ago
#include "../../include/servers/tcp.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());
2 years ago
return rpd_tcp_server_start(app.c_app(), "http://localhost:8080");
}