Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make server::router not move-able. #131

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions lib/malloy/server/routing/router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,6 @@ router::add_subrouter(std::string resource, std::unique_ptr<router> sub_router)
return true;
}

bool
router::add_subrouter(std::string resource, router&& sub)
{
return add_subrouter(std::move(resource), std::make_unique<router>(std::move(sub)));
}

void
router::set_server_string(std::string_view str)
{
Expand Down
10 changes: 2 additions & 8 deletions lib/malloy/server/routing/router.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ namespace malloy::server
/**
* Move constructor.
*/
router(router&& other) noexcept = default;
router(router&& other) noexcept = delete;

/**
* Destructor.
Expand All @@ -263,7 +263,7 @@ namespace malloy::server
* @return A reference to the assignee.
*/
router&
operator=(router&& rhs) noexcept = default;
operator=(router&& rhs) noexcept = delete;

/**
* Set the logger to use.
Expand All @@ -283,12 +283,6 @@ namespace malloy::server
bool
add_subrouter(std::string resource, std::unique_ptr<router> sub_router);

/**
* @copydoc add_subrouter
*/
bool
add_subrouter(std::string resource, router&& sub_router);

/**
* Add an HTTP regex endpoint.
*
Expand Down
3 changes: 2 additions & 1 deletion lib/malloy/server/routing_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ using namespace malloy::server;

routing_context::routing_context(config cfg) :
m_cfg{std::move(cfg)},
m_router{m_cfg.logger != nullptr ? m_cfg.logger->clone("router") : nullptr, m_cfg.agent_string}
m_router{new server::router{m_cfg.logger != nullptr ? m_cfg.logger->clone("router") : nullptr,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This constructor is private 😢 Cannot use make_unique.

m_cfg.agent_string}}
{
m_cfg.validate();

Expand Down
10 changes: 4 additions & 6 deletions lib/malloy/server/routing_context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,10 @@ namespace malloy::server
* @return The top-level router.
*/
[[nodiscard]]
constexpr
const malloy::server::router&
router() const noexcept
{
return m_router;
return *m_router;
}

/**
Expand All @@ -120,16 +119,15 @@ namespace malloy::server
* @return The top-level router.
*/
[[nodiscard]]
constexpr
malloy::server::router&
router() noexcept
{
return m_router;
return *m_router;
}

private:
config m_cfg;
malloy::server::router m_router;
std::unique_ptr<malloy::server::router> m_router;
#if MALLOY_FEATURE_TLS
std::unique_ptr<boost::asio::ssl::context> m_tls_ctx;
#endif
Expand All @@ -154,7 +152,7 @@ namespace malloy::server
nullptr,
#endif
boost::asio::ip::tcp::endpoint{boost::asio::ip::make_address(ctrl.m_cfg.interface), ctrl.m_cfg.port},
std::make_shared<class router>(std::move(ctrl.m_router)),
std::move(ctrl.m_router),
std::make_shared<std::filesystem::path>(ctrl.m_cfg.doc_root),
ctrl.m_cfg.agent_string);

Expand Down
Loading