5G-MAG Reference Tools - MBMS Middleware
RestHandler.h
Go to the documentation of this file.
1 // 5G-MAG Reference Tools
2 // MBMS Middleware Process
3 //
4 // Copyright (C) 2021 Klaus Kühnhammer (Österreichische Rundfunksender GmbH & Co KG)
5 //
6 // Licensed under the License terms and conditions for use, reproduction, and
7 // distribution of 5G-MAG software (the “License”). You may not use this file
8 // except in compliance with the License. You may obtain a copy of the License at
9 // https://www.5g-mag.com/reference-tools. Unless required by applicable law or
10 // agreed to in writing, software distributed under the License is distributed on
11 // an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12 // or implied.
13 //
14 // See the License for the specific language governing permissions and limitations
15 // under the License.
16 //
17 #pragma once
18 #include <string>
19 #include <vector>
20 #include <map>
21 #include <memory>
22 #include <libconfig.h++>
23 
24 #include "cpprest/json.h"
25 #include "cpprest/http_listener.h"
26 #include "cpprest/uri.h"
27 #include "cpprest/asyncrt_utils.h"
28 #include "cpprest/filestream.h"
29 #include "cpprest/rawptrstream.h"
30 #include "cpprest/containerstream.h"
31 #include "cpprest/producerconsumerstream.h"
32 
33 #include "File.h"
34 #include "Service.h"
35 #include "ServiceAnnouncement.h"
36 #include "CacheManagement.h"
37 
38 namespace MBMS_RT {
42  class RestHandler {
43  public:
50  RestHandler(const libconfig::Config& cfg, const std::string& url, const CacheManagement& cache,
51  const std::unique_ptr<MBMS_RT::ServiceAnnouncement>* service_announcement,
52  const std::map<std::string, std::shared_ptr<MBMS_RT::Service>>& services );
56  virtual ~RestHandler();
57 
58  private:
59 
61  void get(web::http::http_request message);
62  void put(web::http::http_request message);
63  const libconfig::Config& _cfg;
64  // const std::map<std::string, LibFlute::File>& _files;
65  const std::map<std::string, std::shared_ptr<Service>>& _services;
66  const std::unique_ptr<MBMS_RT::ServiceAnnouncement>* _service_announcement_h = {};
68 
69  std::unique_ptr<web::http::experimental::listener::http_listener> _listener;
70  bool _require_bearer_token = false;
71  std::string _api_key;
72  std::string _api_path;
73  };
74 };
The RESTful API handler.
Definition: RestHandler.h:42
unsigned _total_cache_size
Definition: RestHandler.h:67
const std::unique_ptr< MBMS_RT::ServiceAnnouncement > * _service_announcement_h
Definition: RestHandler.h:66
RestHandler(const libconfig::Config &cfg, const std::string &url, const CacheManagement &cache, const std::unique_ptr< MBMS_RT::ServiceAnnouncement > *service_announcement, const std::map< std::string, std::shared_ptr< MBMS_RT::Service >> &services)
Default constructor.
Definition: RestHandler.cpp:35
void put(web::http::http_request message)
std::unique_ptr< web::http::experimental::listener::http_listener > _listener
Definition: RestHandler.h:69
void get(web::http::http_request message)
Definition: RestHandler.cpp:79
std::string _api_path
Definition: RestHandler.h:72
virtual ~RestHandler()
Default destructor.
const libconfig::Config & _cfg
Definition: RestHandler.h:63
const CacheManagement & _cache
Definition: RestHandler.h:60
std::string _api_key
Definition: RestHandler.h:71
const std::map< std::string, std::shared_ptr< Service > > & _services
Definition: RestHandler.h:65
static Config cfg
Global configuration object.
Definition: main.cpp:111