Skip to content

Instantly share code, notes, and snippets.

@planaria
Created February 28, 2016 15:32
Show Gist options
  • Save planaria/e6ae4ef822d81b021b08 to your computer and use it in GitHub Desktop.
Save planaria/e6ae4ef822d81b021b08 to your computer and use it in GitHub Desktop.
Hello World in kumori
#include <iostream>
#include <iomanip>
#include <kumori/kumori.hpp>
class application_server : public kumori::http_server<application_server>
{
public:
explicit application_server(boost::asio::io_service& service)
: http_server(service)
{
}
void on_get(kumori::http_server_context& context, bool head)
{
context.response().set_content_type("text/plain");
context.write_headers();
if (head)
return;
auto& stream = context.response_stream();
stream << "Hello, World!" << std::endl;
}
};
int main(int /*argc*/, char* /*argv*/[])
{
try
{
boost::asio::io_service service;
application_server server(service);
server.start();
service.run();
}
catch (std::exception& e)
{
std::cerr << e.what() << std::endl;
return -1;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment