Skip to content

Commit 3873fe6

Browse files
committed
oak: Refactor RequestStub to its own private header file
1 parent 4a9bbbf commit 3873fe6

File tree

5 files changed

+46
-13
lines changed

5 files changed

+46
-13
lines changed

oak/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ set_target_properties(${target} PROPERTIES
2525
CXX_STANDARD_REQUIRED ON
2626
)
2727
target_include_directories(${target}
28+
PRIVATE
29+
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>"
2830
PUBLIC
2931
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
3032
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"

oak/include/oak/server.hpp

-13
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,6 @@ namespace oak {
3939
class ServerImplHandler;
4040
using ServerImpl = boost::network::http::server<ServerImplHandler>;
4141

42-
class RequestStub : public cloe::Request {
43-
public:
44-
cloe::RequestMethod method() const override { throw ERROR; }
45-
cloe::ContentType type() const override { throw ERROR; }
46-
const std::string& body() const override { throw ERROR; }
47-
const std::string& uri() const override { throw ERROR; }
48-
const std::string& endpoint() const override { throw ERROR; }
49-
const std::map<std::string, std::string>& query_map() const override { throw ERROR; }
50-
51-
private:
52-
const std::logic_error ERROR = std::logic_error("using the request in any way is erroneous");
53-
};
54-
5542
/**
5643
* ServerImplHandler is the main request handler for the server.
5744
*

oak/src/oak/registrar.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
#include <cloe/core.hpp> // for Json, logger::get
3030
#include "oak/server.hpp" // for Server
31+
#include "oak/request_stub.hpp" // for RequestStub
3132

3233
namespace oak {
3334

oak/src/oak/request_stub.hpp

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright 2023 Robert Bosch GmbH
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* SPDX-License-Identifier: Apache-2.0
17+
*/
18+
/**
19+
* \file oak/request_stub.hpp
20+
*/
21+
22+
#pragma once
23+
24+
#include <cloe/handler.hpp> // for Request
25+
26+
namespace oak {
27+
28+
class RequestStub : public cloe::Request {
29+
public:
30+
cloe::RequestMethod method() const override { throw ERROR; }
31+
cloe::ContentType type() const override { throw ERROR; }
32+
const std::string& body() const override { throw ERROR; }
33+
const std::string& uri() const override { throw ERROR; }
34+
const std::string& endpoint() const override { throw ERROR; }
35+
const std::map<std::string, std::string>& query_map() const override { throw ERROR; }
36+
37+
private:
38+
const std::logic_error ERROR = std::logic_error("using the request in any way is erroneous");
39+
};
40+
41+
} // namespace oak

oak/src/oak/server.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
#include <cloe/handler.hpp> // for Request
4141
using namespace cloe; // NOLINT(build/namespaces)
4242

43+
#include "oak/request_stub.hpp" // for RequestStub
44+
4345
namespace oak {
4446

4547
namespace {

0 commit comments

Comments
 (0)