Skip to content

Commit 899e09f

Browse files
committed
Use raw string pointers for parameters in different string_view types
1 parent acc691d commit 899e09f

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

samples/proxy/client.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ namespace http = beast::http;
4040
namespace net = boost::asio;
4141
using tcp = boost::asio::ip::tcp;
4242

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" };
43+
constexpr auto c_host = "127.0.0.1"sv;
44+
constexpr auto c_port = "8080"sv;
45+
constexpr auto c_target = "/graphql"sv;
4646
constexpr int c_version = 11; // HTTP 1.1
4747

4848
class Query
@@ -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-
[](net::string_view host,
99-
net::string_view port,
100-
net::string_view target,
98+
[](const char* host,
99+
const char* port,
100+
const char* 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
@@ -151,7 +151,7 @@ std::future<std::string> Query::getRelay(std::string&& queryArg,
151151
}
152152

153153
co_return std::string { std::move(res.body()) };
154-
}(m_host, m_port, m_target, m_version, std::move(requestBody)),
154+
}(m_host.c_str(), m_port.c_str(), m_target.c_str(), m_version, std::move(requestBody)),
155155
net::use_future);
156156

157157
ioc.run();

samples/proxy/server.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ using tcp_stream = typename beast::tcp_stream::rebind_executor<
4848

4949
constexpr net::string_view c_host { "127.0.0.1" };
5050
constexpr unsigned short c_port = 8080;
51-
constexpr net::string_view c_target { "/graphql" };
51+
constexpr beast::string_view c_target { "/graphql" };
5252

5353
// Based on:
5454
// https://www.boost.org/doc/libs/1_82_0/libs/beast/example/http/server/awaitable/http_server_awaitable.cpp

0 commit comments

Comments
 (0)