Skip to content

Commit acc691d

Browse files
committed
Use net::string_view more consistently for Boost.Asio APIs
1 parent 268bd9b commit acc691d

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

samples/proxy/client.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@
3333

3434
using namespace std::literals;
3535

36-
constexpr boost::asio::string_view c_host { "127.0.0.1" };
37-
constexpr boost::asio::string_view c_port { "8080" };
38-
constexpr boost::asio::string_view c_target { "/graphql" };
39-
constexpr int c_version = 11; // HTTP 1.1
40-
4136
using namespace graphql;
4237

4338
namespace beast = boost::beast;
4439
namespace http = beast::http;
4540
namespace net = boost::asio;
4641
using tcp = boost::asio::ip::tcp;
4742

43+
constexpr net::string_view c_host { "127.0.0.1" };
44+
constexpr net::string_view c_port { "8080" };
45+
constexpr net::string_view c_target { "/graphql" };
46+
constexpr int c_version = 11; // HTTP 1.1
47+
4848
class Query
4949
{
5050
public:
@@ -95,9 +95,9 @@ std::future<std::string> Query::getRelay(std::string&& queryArg,
9595
net::io_context ioc;
9696
auto future = net::co_spawn(
9797
ioc,
98-
[](std::string_view host,
99-
std::string_view port,
100-
std::string_view target,
98+
[](net::string_view host,
99+
net::string_view port,
100+
net::string_view target,
101101
int version,
102102
std::string requestBody) -> net::awaitable<std::string> {
103103
// These objects perform our I/O. They use an executor with a default completion token

samples/proxy/server.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@
3636

3737
using namespace std::literals;
3838

39-
constexpr boost::asio::string_view c_host { "127.0.0.1" };
40-
constexpr unsigned short c_port = 8080;
41-
constexpr boost::asio::string_view c_target { "/graphql" };
42-
4339
using namespace graphql;
4440

4541
namespace beast = boost::beast;
@@ -50,6 +46,10 @@ using tcp = boost::asio::ip::tcp;
5046
using tcp_stream = typename beast::tcp_stream::rebind_executor<
5147
net::use_awaitable_t<>::executor_with_default<net::any_io_executor>>::other;
5248

49+
constexpr net::string_view c_host { "127.0.0.1" };
50+
constexpr unsigned short c_port = 8080;
51+
constexpr net::string_view c_target { "/graphql" };
52+
5353
// Based on:
5454
// https://www.boost.org/doc/libs/1_82_0/libs/beast/example/http/server/awaitable/http_server_awaitable.cpp
5555
int main()

0 commit comments

Comments
 (0)