|
| 1 | +/* |
| 2 | + This file is part of libhttpserver |
| 3 | + Copyright (C) 2011, 2012, 2013, 2014, 2015 Sebastiano Merlino |
| 4 | +
|
| 5 | + This library is free software; you can redistribute it and/or |
| 6 | + modify it under the terms of the GNU Lesser General Public |
| 7 | + License as published by the Free Software Foundation; either |
| 8 | + version 2.1 of the License, or (at your option) any later version. |
| 9 | +
|
| 10 | + This library is distributed in the hope that it will be useful, |
| 11 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | + Lesser General Public License for more details. |
| 14 | +
|
| 15 | + You should have received a copy of the GNU Lesser General Public |
| 16 | + License along with this library; if not, write to the Free Software |
| 17 | + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
| 18 | + USA |
| 19 | +*/ |
| 20 | + |
1 | 21 | #include <cstdlib> |
2 | 22 | #include <memory> |
3 | 23 |
|
|
6 | 26 | #define PATH "/plaintext" |
7 | 27 | #define BODY "Hello, World!" |
8 | 28 |
|
9 | | -using namespace httpserver; |
10 | | - |
11 | | -class hello_world_resource : public http_resource { |
12 | | - public: |
13 | | - hello_world_resource(const std::shared_ptr<http_response>& resp): |
14 | | - resp(resp) |
15 | | - { |
16 | | - } |
| 29 | +class hello_world_resource : public httpserver::http_resource { |
| 30 | + public: |
| 31 | + explicit hello_world_resource(const std::shared_ptr<httpserver::http_response>& resp): |
| 32 | + resp(resp) { |
| 33 | + } |
17 | 34 |
|
18 | | - const std::shared_ptr<http_response> render(const http_request&) { |
19 | | - return resp; |
20 | | - } |
| 35 | + const std::shared_ptr<httpserver::http_response> render(const httpserver::http_request&) { |
| 36 | + return resp; |
| 37 | + } |
21 | 38 |
|
22 | | - private: |
23 | | - std::shared_ptr<http_response> resp; |
| 39 | + private: |
| 40 | + std::shared_ptr<httpserver::http_response> resp; |
24 | 41 | }; |
25 | 42 |
|
26 | | -int main(int argc, char** argv) |
27 | | -{ |
28 | | - webserver ws = create_webserver(atoi(argv[1])) |
29 | | - .start_method(http::http_utils::INTERNAL_SELECT) |
| 43 | +int main(int argc, char** argv) { |
| 44 | + std::ignore = argc; |
| 45 | + |
| 46 | + httpserver::webserver ws = httpserver::create_webserver(atoi(argv[1])) |
| 47 | + .start_method(httpserver::http::http_utils::INTERNAL_SELECT) |
30 | 48 | .tcp_nodelay() |
31 | 49 | .max_threads(atoi(argv[2])); |
32 | 50 |
|
33 | | - std::shared_ptr<http_response> hello = std::shared_ptr<http_response>(new string_response(BODY, 200)); |
| 51 | + std::shared_ptr<httpserver::http_response> hello = std::shared_ptr<httpserver::http_response>(new httpserver::string_response(BODY, 200)); |
34 | 52 | hello->with_header("Server", "libhttpserver"); |
35 | 53 |
|
36 | 54 | hello_world_resource hwr(hello); |
|
0 commit comments