diff --git a/examples/demo_service/service.cpp b/examples/demo_service/service.cpp index 49e8e44298..d19e6bb99e 100644 --- a/examples/demo_service/service.cpp +++ b/examples/demo_service/service.cpp @@ -30,23 +30,19 @@ std::string HTML_RESPONSE() { const int color = rand(); - /* HTML Fonts */ - std::string ubuntu_medium = "font-family: \'Ubuntu\', sans-serif; font-weight: 500; "; - std::string ubuntu_normal = "font-family: \'Ubuntu\', sans-serif; font-weight: 400; "; - std::string ubuntu_light = "font-family: \'Ubuntu\', sans-serif; font-weight: 300; "; - - /* HTML */ + // Generate some HTML std::stringstream stream; stream << "" - << "" - << "" - << "

" - << "IncludeOS

" - << "

Now speaks TCP!

" - // .... generate more dynamic content - << "

This is improvised http, but proper stuff is in the works.

" - << "" - << ""; + << " " + << "

" + << "IncludeOS

" + << "

The C++ Unikernel

" + << "

You have successfully booted an IncludeOS TCP service with simple http. " + << "For a more sophisticated example, take a look at " + << "Acorn.

" + << ""; return stream.str(); } @@ -115,8 +111,9 @@ void Service::start(const std::string&) printf(" @on_read: %u bytes received.\n", n); try { + std::string data{(const char*)buf.get(), n}; // try to parse the request - http::Request req{(const char*)buf.get(), n}; + http::Request req{data}; // handle the request, getting a matching response auto res = handle_request(req); @@ -128,12 +125,12 @@ void Service::start(const std::string&) printf(" @on_write: %u bytes written.\n", written); }); } - catch(...) + catch(const std::exception& e) { - printf(" Unable to parse request.\n"); + printf(" Unable to parse request:\n%s\n", e.what()); } }); }); - printf("*** TEST SERVICE STARTED ***\n"); + printf("*** Basic demo service started ***\n"); }