1515.. :Date: Nov 9, 2010
1616.. :Version: 0.8
1717.. :Description: Complete user documentation, with examples, for the :mod:`cpp-netlib`.
18- .. :Copyright: Copyright Glyn Matthews, Dean Michael Berris 2008-2010 .
18+ .. :Copyright: Copyright Glyn Matthews, Dean Michael Berris 2008-2011 .
1919.. Distributed under the Boost Software License, Version
2020.. 1.0. (See accompanying file LICENSE_1_0.txt or copy at
2121.. http://www.boost.org/LICENSE_1_0.txt)
@@ -40,7 +40,7 @@ The :mod:`cpp-netlib` allows you to write semantically consistent code for
4040making different kinds of higher level network applications.
4141
4242The library allows for writing simple code for simple C++ HTTP client
43- applications like :
43+ applications:
4444
4545..code-block ::c++
4646
@@ -53,6 +53,34 @@ applications like:
5353 client::responseresponse _ =client _.get(request);
5454 std::string body = body(response _);
5555
56+ The library also allows for writing simple C++ HTTP servers:
57+
58+ ..code-block ::c++
59+
60+ namespace http = boost::network: :http;
61+
62+ struct handler;
63+ typedef http::server<handler> http_server;
64+
65+ struct handler {
66+ void operator() (http_server::request const &request _,
67+ http_server::response &response _) {
68+ response = http_server::response: :stock_reply(
69+ http_server::response: :ok, "Hello, world!");
70+ }
71+
72+ void log(http_server::string_type const & info) {
73+ std::cerr << "ERROR: " << info << '\n ';
74+ }
75+
76+ };
77+
78+ int main(int arg, char * argv[]) {
79+ handlerhandler _;
80+ http_server server_("0.0.0.0", "8000",handler _);
81+ server _.run();
82+ }
83+
5684The:mod: `cpp-netlib ` is being developed for eventual submission toBoost _.
5785
5886Download