detach PIHTTPServer::Endpoint to base struct PIHTTP::ServerEndpoint (private header), no functionality changes in HTTP server
Ready to implement this private base struct to MQTT client
This commit is contained in:
@@ -210,6 +210,11 @@ public:
|
||||
PIP_EXPORT const char * methodName(Method m);
|
||||
|
||||
|
||||
//! \~english Request handler used by registered routes and fallback processing.
|
||||
//! \~russian Обработчик запроса, используемый зарегистрированными маршрутами и fallback-обработкой.
|
||||
using RequestFunction = std::function<PIHTTP::MessageMutable(const PIHTTP::MessageConst &)>;
|
||||
|
||||
|
||||
}; // namespace PIHTTP
|
||||
|
||||
|
||||
|
||||
@@ -102,43 +102,9 @@ public:
|
||||
void clearReplyHeaders() { reply_headers.clear(); }
|
||||
|
||||
private:
|
||||
struct PathElement {
|
||||
enum class Type {
|
||||
Invalid = 0x01,
|
||||
Fixed = 0x02,
|
||||
Arguments = 0x04,
|
||||
AnyOne = 0x08,
|
||||
AnyPart = 0x10,
|
||||
AnyMany = 0x20
|
||||
};
|
||||
|
||||
Type type = Type::Fixed;
|
||||
PIString source;
|
||||
PIStringList parts;
|
||||
PIMap<int, PIString> arguments;
|
||||
|
||||
PathElement(const PIString & reg = {});
|
||||
|
||||
bool match(const PIString & in, PIMap<PIString, PIString> & ext_args) const;
|
||||
uint priority() const;
|
||||
};
|
||||
|
||||
struct Endpoint {
|
||||
PIStringList path;
|
||||
PIHTTP::Method method = PIHTTP::Method::Unknown;
|
||||
RequestFunction function;
|
||||
PIFlags<PathElement::Type> path_types;
|
||||
PIVector<PathElement> prepared_path;
|
||||
uint priority = 0;
|
||||
|
||||
bool create(const PIString & p);
|
||||
bool match(const PIStringList & in_path, PIMap<PIString, PIString> & ext_args) const;
|
||||
};
|
||||
|
||||
static PIStringList splitPath(const PIString & path);
|
||||
PRIVATE_DECLARATION(PIP_HTTP_SERVER_EXPORT)
|
||||
|
||||
PIMap<PIString, PIString> reply_headers;
|
||||
PIMap<uint, PIVector<Endpoint>> endpoints;
|
||||
RequestFunction unhandled;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user