Compare commits

2 Commits

Author SHA1 Message Date
dfdc4b8bdc add overload for PIHTTPServer::register* for pointer to a member function 2025-04-30 15:07:25 +03:00
8a61cfe7ef new cmake 2025-04-29 21:50:17 +03:00
3 changed files with 16 additions and 3 deletions

View File

@@ -1,5 +1,8 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.13)
cmake_policy(SET CMP0017 NEW) # need include() with .cmake
if (POLICY CMP0177)
cmake_policy(SET CMP0177 OLD)
endif()
project(PIP)
set(PIP_MAJOR 4)
set(PIP_MINOR 7)
@@ -13,7 +16,7 @@ if (NOT DEFINED SHSTKPROJECT)
set(ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cmake-download/CMakeLists.txt"
"# This file was generated by PIP CMake, don`t edit it!
cmake_minimum_required(VERSION 2.8.2)
cmake_minimum_required(VERSION 3.13)
project(cmake-download NONE)
include(ExternalProject)
ExternalProject_Add(cmake

View File

@@ -3,7 +3,7 @@
#include "pihttpconstants.h"
#include "pip_export.h"
#include "pistring.h"
#include "pistringlist.h"
namespace PIHTTP {
@@ -14,6 +14,7 @@ public:
PIHTTP::Method method() const { return m_method; }
PIHTTP::Code code() const { return m_code; }
const PIString & path() const { return m_path; }
PIStringList pathList() const { return m_path.split('/').removeAll({}); }
const PIByteArray & body() const { return m_body; }
const PIMap<PIString, PIString> & headers() const { return m_headers; }
const PIMap<PIString, PIString> & arguments() const { return m_arguments; }

View File

@@ -13,7 +13,16 @@ public:
using RequestFunction = std::function<PIHTTP::MessageMutable(const PIHTTP::MessageConst &)>;
void registerPath(const PIString & path, PIHTTP::Method method, RequestFunction functor);
template<typename T>
void
registerPath(const PIString & path, PIHTTP::Method method, T * o, PIHTTP::MessageMutable (T::*function)(const PIHTTP::MessageConst &)) {
registerPath(path, method, [o, function](const PIHTTP::MessageConst & m) { return (o->*function)(m); });
}
void registerUnhandled(RequestFunction functor);
template<typename T>
void registerUnhandled(T * o, PIHTTP::MessageMutable (T::*function)(const PIHTTP::MessageConst &)) {
registerUnhandled([o, function](const PIHTTP::MessageConst & m) { return (o->*function)(m); });
}
void unregisterPath(const PIString & path, PIHTTP::Method method);
void unregisterPath(const PIString & path);