Created
February 28, 2016 15:32
-
-
Save planaria/e6ae4ef822d81b021b08 to your computer and use it in GitHub Desktop.
Hello World in kumori
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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