Files
ylib/include/net/http_interceptor.h
xx ef63cfd6aa 1、删除部分三方库
2、整合ylib为一个lib库
2024-05-26 12:51:32 +08:00

41 lines
1.2 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#pragma once
#include "define.h"
#if USE_NET_HTTP_WEBSITE
#include <regex>
#include <functional>
#include "net/http_interface.h"
#include "util/array.hpp"
namespace ylib
{
namespace network
{
namespace http
{
class reqpack;
struct interceptor_info {
std::regex express;
std::string express_string;
std::function<bool(network::http::reqpack* rp)> callback;
};
/******************************************************
* class拦截器
******************************************************/
class interceptor :public ylib::error_base, public network::http::interface_
{
public:
interceptor();
~interceptor();
size_t add(const std::string& regex_express, std::function<bool(network::http::reqpack* rp)> callback);
void remove(size_t index);
bool trigger(const std::string& url, network::http::reqpack* rp);
private:
ylib::nolock_array<interceptor_info*> m_array;
};
}
}
}
#endif