UniSet  2.24.2
UHttpServer.h
1 #ifndef DISABLE_REST_API
2 /*
3  * Copyright (c) 2015 Pavel Vainerman.
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as
7  * published by the Free Software Foundation, version 2.1.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Lesser Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 // -------------------------------------------------------------------------
18 #ifndef UHttpServer_H_
19 #define UHttpServer_H_
20 // -------------------------------------------------------------------------
21 #include <string>
22 #include <memory>
23 #include <Poco/Net/HTTPServer.h>
24 #include "DebugStream.h"
25 #include "ThreadCreator.h"
26 #include "UHttpRequestHandler.h"
27 // -------------------------------------------------------------------------
31 // -------------------------------------------------------------------------
32 namespace uniset
33 {
34  namespace UHttp
35  {
37  {
38  public:
39 
40  UHttpServer( std::shared_ptr<IHttpRequestRegistry>& supplier, const std::string& host, int port );
41  virtual ~UHttpServer();
42 
43  void start();
44  void stop();
45 
46  std::shared_ptr<DebugStream> log();
47 
48  // (CORS): Access-Control-Allow-Origin. Default: *
49  void setCORS_allow( const std::string& CORS_allow );
50  protected:
51  UHttpServer();
52 
53  private:
54 
55  std::shared_ptr<DebugStream> mylog;
56  Poco::Net::SocketAddress sa;
57 
58  std::shared_ptr<Poco::Net::HTTPServer> http;
59  std::shared_ptr<UHttpRequestHandlerFactory> reqFactory;
60 
61  };
62  }
63 }
64 // -------------------------------------------------------------------------
65 #endif // UHttpServer_H_
66 // -------------------------------------------------------------------------
67 #endif
Definition: UHttpServer.h:37
Definition: CommonEventLoop.h:15