15
15
.. :Date: Nov 9, 2010
16
16
.. :Version: 0.8
17
17
.. :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 .
19
19
.. Distributed under the Boost Software License, Version
20
20
.. 1.0. (See accompanying file LICENSE_1_0.txt or copy at
21
21
.. http://www.boost.org/LICENSE_1_0.txt)
@@ -40,7 +40,7 @@ The :mod:`cpp-netlib` allows you to write semantically consistent code for
40
40
making different kinds of higher level network applications.
41
41
42
42
The library allows for writing simple code for simple C++ HTTP client
43
- applications like :
43
+ applications:
44
44
45
45
.. code-block :: c++
46
46
@@ -53,6 +53,34 @@ applications like:
53
53
client::response response _ = client _.get(request);
54
54
std::string body = body(response _);
55
55
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
+ handler handler _;
80
+ http_server server_("0.0.0.0", "8000", handler _);
81
+ server _.run();
82
+ }
83
+
56
84
The :mod: `cpp-netlib ` is being developed for eventual submission to Boost _.
57
85
58
86
Download
0 commit comments