xrtHttpRouterConfigInit
初始化最多 4096 条路由、16384 个节点和 4 MiB 文本的默认配置;存储可以未对齐。
void xrtHttpRouterConfigInit(xhttprouterconfig* pConfig);
| 参数 | 说明 |
|---|---|
| xhttprouterconfig* pConfig | 配置结构 |
返回:初始化最多 4096 条路由、16384 个节点和 4 MiB 文本的默认配置;存储可以未对齐。
示例已编译验证
httprouterconfiginit obj; xrtHttpRouterConfigInit(&obj);
xrtHttpRouterCreate
创建空 Router;配置可以未对齐,并在返回前被按值持有。
xhttprouter* xrtHttpRouterCreate( const xhttprouterconfig* pConfig );
| 参数 | 说明 |
|---|---|
| const xhttprouterconfig* pConfig | 配置结构 |
返回:创建空 Router;配置可以未对齐,并在返回前被按值持有。
示例已编译验证
/* 创建空 Router;配置可以未对齐,并在返回前被按值持有。 */ xhandle* h = xrtHttpRouterCreate();
xrtHttpRouterDestroy
销毁 Router 自身资源;注册 Value 始终由调用方持有。
void xrtHttpRouterDestroy(xhttprouter* pRouter);
| 参数 | 说明 |
|---|---|
| xhttprouter* pRouter | 路由器 |
返回:销毁 Router 自身资源;注册 Value 始终由调用方持有。
示例已编译验证
xrtHttpRouterDestroy(pRouter);
xrtHttpRouterAdd
XRT_API bool xrtHttpRouterAdd( xhttprouter* pRouter, xstrview Method, xstrview Pattern, ptr pValue );
;
返回:XRT_API bool xrtHttpRouterAdd( xhttprouter* pRouter, xstrview Method, xstrview Pattern, ptr pValue );
示例已编译验证
/* XRT_API bool xrtHttpRouterAdd( xhttprouter* pRouter, xstrview Method, xstrview Pattern, ptr pValue ); */ result = xrtHttpRouterAdd();
xrtHttpRouterFreeze
XRT_API bool xrtHttpRouterFreeze(xhttprouter* pRouter);
;
返回:XRT_API bool xrtHttpRouterFreeze(xhttprouter* pRouter);
示例已编译验证
xrtHttpRouterFreeze(obj);
xrtHttpRouterFrozen
判断 Router 是否已经进入不可变匹配阶段。
bool xrtHttpRouterFrozen(const xhttprouter* pRouter);
| 参数 | 说明 |
|---|---|
| const xhttprouter* pRouter | 路由器 |
返回:判断 Router 是否已经进入不可变匹配阶段。
示例已编译验证
/* 判断 Router 是否已经进入不可变匹配阶段。 */ result = xrtHttpRouterFrozen(pRouter);
xrtHttpRouterCount
返回当前注册路由数量。
size_t xrtHttpRouterCount(const xhttprouter* pRouter);
| 参数 | 说明 |
|---|---|
| const xhttprouter* pRouter | 路由器 |
返回:返回当前注册路由数量。
示例已编译验证
/* 返回当前注册路由数量。 */ result = xrtHttpRouterCount(pRouter);
xrtHttpRouterNodes
返回当前预编译节点数量,空 Router 仍包含根节点。
size_t xrtHttpRouterNodes(const xhttprouter* pRouter);
| 参数 | 说明 |
|---|---|
| const xhttprouter* pRouter | 路由器 |
返回:返回当前预编译节点数量,空 Router 仍包含根节点。
示例已编译验证
/* 返回当前预编译节点数量,空 Router 仍包含根节点。 */ result = xrtHttpRouterNodes(pRouter);
xrtHttpRouterBytes
返回当前实际持有的方法、模板和静态边文本字节数。
size_t xrtHttpRouterBytes(const xhttprouter* pRouter);
| 参数 | 说明 |
|---|---|
| const xhttprouter* pRouter | 路由器 |
返回:返回当前实际持有的方法、模板和静态边文本字节数。
示例已编译验证
/* 返回当前实际持有的方法、模板和静态边文本字节数。 */ result = xrtHttpRouterBytes(pRouter);
xrtHttpRouterMatch
XRT_API xhttprouterstatus xrtHttpRouterMatch( const xhttprouter* pRouter, xstrview Method, xstrview Path, xhttprouteparam* pParams, size_t iCapacity, size_t* pCount, xhttproutermatch* pMatch );
;
返回:XRT_API xhttprouterstatus xrtHttpRouterMatch( const xhttprouter* pRouter, xstrview Method, xstrview Path, xhttprouteparam* pParams, size_t iCapacity, size_t* pCount, xhttproutermatch* pMatch );
示例已编译验证
/* XRT_API xhttprouterstatus xrtHttpRouterMatch( const xhttprouter* pRouter, xstrview Method, xstrview Path, xhttprouteparam* pParams, size_t iCapacity, size_t* pCount, xhttproutermatch* pMatch ); */ result = xrtHttpRouterMatch();
xrtHttpRouterMethods
XRT_API xhttprouterstatus xrtHttpRouterMethods( const xhttprouter* pRouter, xstrview Path, xstrview* pMethods, size_t iCapacity, size_t* pCount );
;
返回:XRT_API xhttprouterstatus xrtHttpRouterMethods( const xhttprouter* pRouter, xstrview Path, xstrview* pMethods, size_t iCapacity, size_t* pCount );
示例已编译验证
/* XRT_API xhttprouterstatus xrtHttpRouterMethods( const xhttprouter* pRouter, xstrview Path, xstrview* pMethods, size_t iCapacity, size_t* pCount ); */ result = xrtHttpRouterMethods();