|
NexusForce 1.0.0
A rigorously engineered full-stack C++ backend library.
|
异步过滤器基类(回调模式) 更多...
#include <async_filter.hpp>
Public 类型 | |
| using | next_callback = function<void(bool should_continue)> |
| 异步继续回调 | |
Public 成员函数 | |
| virtual void | pre_filter_async (http_request &request, http_response &response, http_context &ctx, next_callback next) |
| 异步预过滤 | |
| virtual void | post_filter_async (http_request &request, http_response &response, http_context &ctx, next_callback next) |
| 异步后过滤 | |
| Public 成员函数 继承自 neforce::http::http_filter | |
| virtual void | do_filter (http_request &request, http_response &response)=0 |
| 核心过滤方法 | |
| virtual bool | pre_filter (http_request &request, http_response &response) |
| 预处理方法 | |
| virtual void | post_filter (http_request &request, http_response &response) |
| 后处理方法 | |
| virtual string | name () const |
| 获取过滤器名称 | |
异步过滤器基类(回调模式)
扩展 http_filter,为需要异步 I/O 的中间件提供回调式异步接口。。
使用流程:
无异步过滤器时,http_router 走零开销同步路径。
在文件 async_filter.hpp 第 31 行定义.
| using neforce::http::async_filter::next_callback = function<void(bool should_continue)> |
|
inlinevirtual |
异步后过滤
| request | HTTP请求 |
| response | HTTP响应 |
| ctx | 请求上下文 |
| next | 完成时调用 |
默认实现直接调用 post_filter 并 next(true)。
在文件 async_filter.hpp 第 66 行定义.
引用了 neforce::next() , 以及 neforce::http::http_filter::post_filter().
|
inlinevirtual |
异步预过滤
| request | HTTP请求 |
| response | HTTP响应(可预设以中断处理) |
| ctx | 请求上下文(跨中间件数据传递) |
| next | 完成时调用 next(true) 继续或 next(false) 中断 |
默认实现直接调用 next(true),等效于同步 pre_filter 返回 true。
在文件 async_filter.hpp 第 48 行定义.
引用了 neforce::next() , 以及 neforce::http::http_filter::pre_filter().