diff options
author | Håvard Pettersen <havardpe@oath.com> | 2018-12-17 14:52:38 +0000 |
---|---|---|
committer | Håvard Pettersen <havardpe@oath.com> | 2018-12-17 14:52:38 +0000 |
commit | 49e2c28d35007db575be3653d1fb9715d40df687 (patch) | |
tree | 6769e9a12ce448d51a17c15d93f008ed8e7cbd09 /vespalib | |
parent | b3e51f84ba5c8bc01c8bbff84621e82a375b54f2 (diff) |
let GET callback be non-const
Diffstat (limited to 'vespalib')
-rw-r--r-- | vespalib/src/tests/portal/portal_test.cpp | 2 | ||||
-rw-r--r-- | vespalib/src/vespa/vespalib/portal/portal.cpp | 6 | ||||
-rw-r--r-- | vespalib/src/vespa/vespalib/portal/portal.h | 10 |
3 files changed, 9 insertions, 9 deletions
diff --git a/vespalib/src/tests/portal/portal_test.cpp b/vespalib/src/tests/portal/portal_test.cpp index 6d0d04620d0..299340fd131 100644 --- a/vespalib/src/tests/portal/portal_test.cpp +++ b/vespalib/src/tests/portal/portal_test.cpp @@ -83,7 +83,7 @@ struct MyGetHandler : public Portal::GetHandler { std::function<void(Portal::GetRequest)> fun; template <typename F> MyGetHandler(F &&f) : fun(std::move(f)) {} - void get(Portal::GetRequest request) const override { + void get(Portal::GetRequest request) override { fun(std::move(request)); } ~MyGetHandler(); diff --git a/vespalib/src/vespa/vespalib/portal/portal.cpp b/vespalib/src/vespa/vespalib/portal/portal.cpp index 031f364faff..0d62d5728d1 100644 --- a/vespalib/src/vespa/vespalib/portal/portal.cpp +++ b/vespalib/src/vespa/vespalib/portal/portal.cpp @@ -88,7 +88,7 @@ Portal::cancel_token(Token &token) } portal::HandleGuard -Portal::lookup_get_handler(const vespalib::string &uri, const GetHandler *&handler) +Portal::lookup_get_handler(const vespalib::string &uri, GetHandler *&handler) { std::lock_guard guard(_lock); for (const auto &entry: _bind_list) { @@ -130,7 +130,7 @@ Portal::handle_http(portal::HttpConnection *conn) } else if (!conn->get_request().is_get()) { conn->respond_with_error(501, "Not Implemented"); } else { - const GetHandler *get_handler = nullptr; + GetHandler *get_handler = nullptr; auto guard = lookup_get_handler(conn->get_request().get_uri(), get_handler); if (guard.valid()) { assert(get_handler != nullptr); @@ -182,7 +182,7 @@ Portal::create(CryptoEngine::SP crypto, int port) } Portal::Token::UP -Portal::bind(const vespalib::string &path_prefix, const GetHandler &handler) +Portal::bind(const vespalib::string &path_prefix, GetHandler &handler) { auto token = make_token(); std::lock_guard guard(_lock); diff --git a/vespalib/src/vespa/vespalib/portal/portal.h b/vespalib/src/vespa/vespalib/portal/portal.h index aa696c85fa2..93424dda90c 100644 --- a/vespalib/src/vespa/vespalib/portal/portal.h +++ b/vespalib/src/vespa/vespalib/portal/portal.h @@ -67,7 +67,7 @@ public: }; struct GetHandler { - virtual void get(GetRequest request) const = 0; + virtual void get(GetRequest request) = 0; virtual ~GetHandler(); }; @@ -75,8 +75,8 @@ private: struct BindState { uint64_t handle; vespalib::string prefix; - const GetHandler *handler; - BindState(uint64_t handle_in, vespalib::string prefix_in, const GetHandler &handler_in) + GetHandler *handler; + BindState(uint64_t handle_in, vespalib::string prefix_in, GetHandler &handler_in) : handle(handle_in), prefix(prefix_in), handler(&handler_in) {} bool operator<(const BindState &rhs) const { if (prefix.size() == rhs.prefix.size()) { @@ -98,7 +98,7 @@ private: Token::UP make_token(); void cancel_token(Token &token); - portal::HandleGuard lookup_get_handler(const vespalib::string &uri, const GetHandler *&handler); + portal::HandleGuard lookup_get_handler(const vespalib::string &uri, GetHandler *&handler); void evict_handle(uint64_t handle); void handle_accept(portal::HandleGuard guard, SocketHandle socket); @@ -110,7 +110,7 @@ public: static SP create(CryptoEngine::SP crypto, int port); int listen_port() const { return _listener->listen_port(); } const vespalib::string &my_host() const { return _my_host; } - Token::UP bind(const vespalib::string &path_prefix, const GetHandler &handler); + Token::UP bind(const vespalib::string &path_prefix, GetHandler &handler); }; } // namespace vespalib |