/* Copyright 2008-2009 Felspar Co Ltd. http://fost.3.felspar.com/ Distributed under the Boost Software License, Version 1.0. See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt */ #include #include #include #include using namespace fostlib; namespace { setting< string > c_host( L"http-threaded", L"Server", L"Bind to", L"localhost" ); setting< int > c_port( L"http-threaded", L"Server", L"Port", 8001 ); bool service( http::server::request &req ) { text_body response( L"This is a response", mime::mime_headers(), L"text/html" ); req( response ); return true; } } FSL_MAIN( L"http-threaded", L"Threaded HTTP server\nCopyright (c) 2009, Felspar Co. Ltd." )( fostlib::ostream &o, fostlib::arguments &args ) { // Bind server to host and port http::server server( host( args[1].value(c_host.value()) ), c_port.value() ); o << L"Answering requests on http://" << server.binding() << L":" << server.port() << L"/" << std::endl; // Service requests server( service ); // It will never get this far return 0; }