M module-services/service-desktop/CMakeLists.txt => module-services/service-desktop/CMakeLists.txt +1 -0
@@ 34,6 34,7 @@ set(SOURCES
endpoints/filesystem/FileContext.cpp
endpoints/security/SecurityEndpoint.cpp
endpoints/security/SecurityEndpointHelper.cpp
+ endpoints/nullEndpoint/NullEndpoint.cpp
parser/HttpEnums.cpp
parser/ParserFSM.cpp
M module-services/service-desktop/endpoints/EndpointFactory.hpp => module-services/service-desktop/endpoints/EndpointFactory.hpp +2 -1
@@ 19,6 19,7 @@
#include "update/UpdateEndpoint.hpp"
#include <endpoints/bluetooth/BluetoothEndpoint.hpp>
#include "security/SecurityEndpoint.hpp"
+#include "nullEndpoint/NullEndpoint.hpp"
class EndpointFactory
{
@@ 56,7 57,7 @@ class EndpointFactory
case parserFSM::EndpointType::usbSecurity:
return std::make_unique<SecurityEndpoint>(ownerServicePtr);
default:
- return nullptr;
+ return std::make_unique<NullEndpoint>(ownerServicePtr);
}
}
};
A module-services/service-desktop/endpoints/nullEndpoint/NullEndpoint.cpp => module-services/service-desktop/endpoints/nullEndpoint/NullEndpoint.cpp +13 -0
@@ 0,0 1,13 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include "NullEndpoint.hpp"
+
+using namespace parserFSM;
+
+auto NullEndpoint::handle(parserFSM::Context &context) -> void
+{
+ context.setResponseStatus(http::Code::BadRequest);
+ MessageHandler::putToSendQueue(context.createSimpleResponse());
+ LOG_DEBUG("Unknown Endpoint #%d", static_cast<int>(context.getEndpoint()));
+}
A module-services/service-desktop/endpoints/nullEndpoint/NullEndpoint.hpp => module-services/service-desktop/endpoints/nullEndpoint/NullEndpoint.hpp +27 -0
@@ 0,0 1,27 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include <endpoints/Endpoint.hpp>
+
+namespace parserFSM
+{
+ class Context;
+} // namespace parserFSM
+
+namespace sys
+{
+ class Service;
+} // namespace sys
+
+class NullEndpoint : public parserFSM::Endpoint
+{
+ public:
+ explicit NullEndpoint(sys::Service *ownerServicePtr) : Endpoint(ownerServicePtr)
+ {
+ debugName = "NullEndpoint";
+ }
+
+ auto handle(parserFSM::Context &context) -> void override;
+};