PIProtectedVariable - user now can`t mistake
PIHTTPServer improvements
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
#ifndef PIHTTPSERVER_H
|
||||
#define PIHTTPSERVER_H
|
||||
|
||||
#include "microhttpd_server_p.h"
|
||||
#include "pip_http_server_export.h"
|
||||
#include "microhttpd_server.h"
|
||||
|
||||
class PIP_HTTP_SERVER_EXPORT PIHTTPServer: public MicrohttpdServer {
|
||||
PIOBJECT_SUBCLASS(PIHTTPServer, MicrohttpdServer)
|
||||
@@ -13,7 +12,10 @@ public:
|
||||
|
||||
using RequestFunction = std::function<MicrohttpdServer::Reply(const MicrohttpdServer::Request &)>;
|
||||
|
||||
void registerPath(const PIString & path, RequestFunction functor);
|
||||
void registerPath(const PIString & path, MicrohttpdServer::Method method, RequestFunction functor);
|
||||
void registerUnhandled(RequestFunction functor);
|
||||
void unregisterPath(const PIString & path, MicrohttpdServer::Method method);
|
||||
void unregisterPath(const PIString & path);
|
||||
|
||||
void addReplyHeader(const PIString & name, const PIString & value) { reply_headers[name] = value; }
|
||||
void removeReplyHeader(const PIString & name) { reply_headers.remove(name); }
|
||||
@@ -23,10 +25,12 @@ private:
|
||||
struct Endpoint {
|
||||
bool match(const PIStringList & in_path) const;
|
||||
PIStringList path;
|
||||
MicrohttpdServer::Method method = MicrohttpdServer::Method::Unknown;
|
||||
RequestFunction function;
|
||||
};
|
||||
PIMap<PIString, PIString> reply_headers;
|
||||
PIMap<PIString, Endpoint> functions;
|
||||
RequestFunction unhandled;
|
||||
};
|
||||
|
||||
|
||||
|
||||
54
libs/main/http_server/pihttpservermodule.h
Normal file
54
libs/main/http_server/pihttpservermodule.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Module includes
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
//! \defgroup HTTPServer HTTPServer
|
||||
//! \~\brief
|
||||
//! \~english HTTP server
|
||||
//! \~russian HTTP сервер
|
||||
//!
|
||||
//! \~\details
|
||||
//! \~english \section cmake_module_HTTPServer Building with CMake
|
||||
//! \~russian \section cmake_module_HTTPServer Сборка с использованием CMake
|
||||
//!
|
||||
//! \~\code
|
||||
//! find_package(PIP REQUIRED)
|
||||
//! target_link_libraries([target] PIP::HTTPServer)
|
||||
//! \endcode
|
||||
//!
|
||||
//! \~english \par Common
|
||||
//! \~russian \par Общее
|
||||
//!
|
||||
//! \~english
|
||||
//! These files provides HTTP server based on libmicrohttpd
|
||||
//!
|
||||
//! \~russian
|
||||
//! Эти файлы обеспечивают HTTP сервер, основанный на libmicrohttpd
|
||||
//!
|
||||
//! \~\authors
|
||||
//! \~english
|
||||
//! Ivan Pelipenko peri4ko@yandex.ru;
|
||||
//! \~russian
|
||||
//! Иван Пелипенко peri4ko@yandex.ru;
|
||||
//!
|
||||
|
||||
#ifndef pihttpservermodule_H
|
||||
#define pihttpservermodule_H
|
||||
|
||||
#include "pihttpserver.h"
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user