UniSet  2.6.0
UHttpServer.h
00001 #ifndef DISABLE_REST_API
00002 /*
00003  * Copyright (c) 2015 Pavel Vainerman.
00004  *
00005  * This program is free software: you can redistribute it and/or modify
00006  * it under the terms of the GNU Lesser General Public License as
00007  * published by the Free Software Foundation, version 2.1.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00012  * Lesser General Lesser Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public License
00015  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 // -------------------------------------------------------------------------
00018 #ifndef UHttpServer_H_
00019 #define UHttpServer_H_
00020 // -------------------------------------------------------------------------
00021 #include <string>
00022 #include <memory>
00023 #include <Poco/Net/HTTPServer.h>
00024 #include "DebugStream.h"
00025 #include "ThreadCreator.h"
00026 #include "UHttpRequestHandler.h"
00027 // -------------------------------------------------------------------------
00031 // -------------------------------------------------------------------------
00032 namespace uniset
00033 {
00034 namespace UHttp
00035 {
00036 class UHttpServer
00037 {
00038     public:
00039 
00040         UHttpServer( std::shared_ptr<IHttpRequestRegistry>& supplier, const std::string& host, int port );
00041         virtual ~UHttpServer();
00042 
00043         void start();
00044         void stop();
00045 
00046         std::shared_ptr<DebugStream> log();
00047 
00048     protected:
00049         UHttpServer();
00050 
00051     private:
00052 
00053         std::shared_ptr<DebugStream> mylog;
00054         Poco::Net::SocketAddress sa;
00055 
00056         std::shared_ptr<Poco::Net::HTTPServer> http;
00057         std::shared_ptr<UHttpRequestHandlerFactory> reqFactory;
00058 
00059 };
00060 }
00061 }
00062 // -------------------------------------------------------------------------
00063 #endif // UHttpServer_H_
00064 // -------------------------------------------------------------------------
00065 #endif