-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved HTTP client behaviour to client library. Also added GET and POS… (
#549) * Moved HTTP client behaviour to client library. Also added GET and POST-specific versions of the smae HTTP client behaviour to make them easier to use * Added copyrights * Fixed typos
- Loading branch information
Showing
9 changed files
with
156 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...2_client_library/http_client/include/http_client/client_behaviors/cb_http_get_request.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2023 RobosoftAI Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
/***************************************************************************************************************** | ||
* | ||
* Authors: Jaycee Lock | ||
* | ||
******************************************************************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include <http_client/cl_http_client.hpp> | ||
#include <http_client/client_behaviors/cb_http_request.hpp> | ||
#include <smacc2/smacc.hpp> | ||
|
||
namespace cl_http | ||
{ | ||
class CbHttpGetRequest : public CbHttpRequestBase | ||
{ | ||
public: | ||
CbHttpGetRequest() : CbHttpRequestBase(ClHttp::kHttpRequestMethod::GET) {} | ||
}; | ||
} // namespace cl_http |
34 changes: 34 additions & 0 deletions
34
..._client_library/http_client/include/http_client/client_behaviors/cb_http_post_request.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2023 RobosoftAI Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
/***************************************************************************************************************** | ||
* | ||
* Authors: Jaycee Lock | ||
* | ||
******************************************************************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include <http_client/cl_http_client.hpp> | ||
#include <http_client/client_behaviors/cb_http_request.hpp> | ||
#include <smacc2/smacc.hpp> | ||
|
||
namespace cl_http | ||
{ | ||
class CbHttpPostRequest : public CbHttpRequestBase | ||
{ | ||
public: | ||
CbHttpPostRequest() : CbHttpRequestBase(ClHttp::kHttpRequestMethod::POST) {} | ||
}; | ||
} // namespace cl_http |
60 changes: 60 additions & 0 deletions
60
smacc2_client_library/http_client/include/http_client/client_behaviors/cb_http_request.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright 2023 RobosoftAI Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
/***************************************************************************************************************** | ||
* | ||
* Authors: Jaycee Lock | ||
* | ||
******************************************************************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include <cstring> | ||
#include <http_client/cl_http_client.hpp> | ||
#include <smacc2/smacc.hpp> | ||
|
||
namespace cl_http | ||
{ | ||
|
||
class CbHttpRequestBase : public smacc2::SmaccClientBehavior | ||
{ | ||
public: | ||
CbHttpRequestBase(const ClHttp::kHttpRequestMethod http_request_type) | ||
: kRequestType(http_request_type) | ||
{ | ||
} | ||
|
||
template <typename TOrthogonal, typename TSourceObject> | ||
void onOrthogonalAllocation() | ||
{ | ||
} | ||
|
||
virtual void runtimeConfigure() override | ||
{ | ||
this->requiresClient(cl_http_); | ||
cl_http_->onResponseReceived(&CbHttpRequestBase::onResponseReceived, this); | ||
} | ||
|
||
virtual void onResponseReceived(const ClHttp::TResponse & response) {} | ||
|
||
virtual void onEntry() override { cl_http_->makeRequest(kRequestType); } | ||
|
||
virtual void onExit() override {} | ||
|
||
private: | ||
const ClHttp::kHttpRequestMethod kRequestType; | ||
|
||
ClHttp * cl_http_; | ||
}; | ||
} // namespace cl_http |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters