2 * nghttp2 - HTTP/2 C Library
4 * Copyright (c) 2014 Tatsuhiro Tsujikawa
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sublicense, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice shall be
15 * included in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 #include "nghttp2_config.h"
27 #include <nghttp2/asio_http2_server.h>
29 #include "asio_server_http2_impl.h"
30 #include "asio_server.h"
35 namespace asio_http2 {
39 http2::http2() : impl_(make_unique<http2_impl>()) {}
43 http2::http2(http2 &&other) noexcept : impl_(std::move(other.impl_)) {}
45 http2 &http2::operator=(http2 &&other) noexcept {
50 impl_ = std::move(other.impl_);
55 boost::system::error_code http2::listen_and_serve(boost::system::error_code &ec,
56 const std::string &address,
57 const std::string &port,
59 return impl_->listen_and_serve(ec, nullptr, address, port, asynchronous);
62 boost::system::error_code http2::listen_and_serve(
63 boost::system::error_code &ec, boost::asio::ssl::context &tls_context,
64 const std::string &address, const std::string &port, bool asynchronous) {
65 return impl_->listen_and_serve(ec, &tls_context, address, port, asynchronous);
68 void http2::num_threads(size_t num_threads) { impl_->num_threads(num_threads); }
70 void http2::backlog(int backlog) { impl_->backlog(backlog); }
72 bool http2::handle(std::string pattern, request_cb cb) {
73 return impl_->handle(std::move(pattern), std::move(cb));
76 void http2::stop() { impl_->stop(); }
78 void http2::join() { return impl_->join(); }
82 } // namespace asio_http2
84 } // namespace nghttp2