Fix dummy values in gRPC message sent to RC xApp
[ric-app/ts.git] / src / utils / restclient.hpp
1 // vi: ts=4 sw=4 noet:
2 /*
3 ==================================================================================
4     Copyright (c) 2022 Alexandre Huff
5
6    Licensed under the Apache License, Version 2.0 (the "License");
7    you may not use this file except in compliance with the License.
8    You may obtain a copy of the License at
9
10        http://www.apache.org/licenses/LICENSE-2.0
11
12    Unless required by applicable law or agreed to in writing, software
13    distributed under the License is distributed on an "AS IS" BASIS,
14    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15    See the License for the specific language governing permissions and
16    limitations under the License.
17 ==================================================================================
18 */
19
20 /*
21     Mnemonic:   restclient.hpp
22     Abstract:   Header for the libcurl wrapper.
23
24     Date:       8 Apr 2022
25     Author:     Alexandre Huff
26 */
27
28
29
30 #ifndef _CURL_WRAPPER_HPP
31 #define _CURL_WRAPPER_HPP
32
33 #include <curl/curl.h>
34 #include <string>
35
36 namespace restclient {
37
38 typedef struct resp {
39     long status_code;
40     std::string body;
41 } response_t;
42
43 class RestClient {
44     private:
45         std::string baseUrl;
46         response_t response;
47         CURL *curl = NULL;
48         struct curl_slist *headers = NULL;
49         char errbuf[CURL_ERROR_SIZE];
50
51         bool init( );
52
53     public:
54         RestClient( std::string baseUrl );
55         ~RestClient();
56         std::string getBaseUrl();
57         response_t do_get( std::string path );
58         response_t do_post( std::string path, std::string json );
59 };
60
61 } // namespace
62
63
64 #endif