优化,增加动态订阅
This commit is contained in:
@@ -1,41 +1,48 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "sol/sol.hpp"
|
||||
#include "core/structs.h"
|
||||
#include "core/define.h"
|
||||
#include "net/http_reqpack.h"
|
||||
#include "net/http_request.h"
|
||||
#include "net/http_response.h"
|
||||
#include "net/http_router.h"
|
||||
#include "util/map.hpp"
|
||||
namespace fastweb
|
||||
{
|
||||
/// <summary>
|
||||
/// 订阅管理器
|
||||
/// </summary>
|
||||
class subscribe_manager:public Interface {
|
||||
class subscribe_manager :public Interface {
|
||||
public:
|
||||
subscribe_manager(fastweb::app* ptr);
|
||||
subscribe_manager(fastweb::app* app);
|
||||
~subscribe_manager();
|
||||
|
||||
void load(network::http::router* router);
|
||||
void start();
|
||||
bool add(const std::string& pattern, const std::string& filepath);
|
||||
bool remove(const std::string& pattern);
|
||||
bool exist(const std::string& pattern);
|
||||
void clear();
|
||||
private:
|
||||
/// <summary>
|
||||
/// 服务回调
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="response"></param>
|
||||
/// <param name="pattern"></param>
|
||||
/// <param name="filepath"></param>
|
||||
bool callback(network::http::request* request, network::http::response* response, const std::string& pattern, const std::string& filepath);
|
||||
/// <summary>
|
||||
/// 其它
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="response"></param>
|
||||
/// <param name="extra"></param>
|
||||
void other(network::http::request* request, network::http::response* response);
|
||||
/// <summary>
|
||||
/// 执行lua
|
||||
/// </summary>
|
||||
/// <param name="filepath"></param>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="response"></param>
|
||||
void exec(const std::string& filepath, network::http::request* request, network::http::response* response);
|
||||
private:
|
||||
network::http::router* m_router = nullptr;
|
||||
std::vector<std::string*> m_subextra;
|
||||
/// <summary>
|
||||
/// 未找到页面
|
||||
/// </summary>
|
||||
/// <param name="response"></param>
|
||||
void send_404(network::http::response* response);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user