xrtHttpServerRouteEventsInit
XRT_API void xrtHttpServerRouteEventsInit( xhttpserverrouteevents* pEvents );
示例已编译验证
httpserverrouteeventsinit obj; xrtHttpServerRouteEventsInit(&obj);
xrtHttpServerRouterCreate
XRT_API xhttpserverrouter* xrtHttpServerRouterCreate( const xhttprouterconfig* pConfig );
示例已编译验证
/* XRT_API xhttpserverrouter* xrtHttpServerRouterCreate( const xhttprouterconfig* pConfig ); */ xhandle* h = xrtHttpServerRouterCreate();
xrtHttpServerRouterRef
增加 Router 引用;冻结后的 Router 可由多个运行中 Server 共享。
| 参数 | 说明 |
|---|---|
| xhttpserverrouter* pRouter | 路由器 |
示例已编译验证
/* 增加 Router 引用;冻结后的 Router 可由多个运行中 Server 共享。 */ result = xrtHttpServerRouterRef(pRouter);
xrtHttpServerRouterDestroy
释放 Router 引用;空指针是安全的空操作。
| 参数 | 说明 |
|---|---|
| xhttpserverrouter* pRouter | 路由器 |
示例已编译验证
xrtHttpServerRouterDestroy(pRouter);
xrtHttpServerRouteEvents
XRT_API bool xrtHttpServerRouteEvents( xhttpserverrouter* pRouter, xstrview Method, xstrview Pattern, const xhttpserverrouteevents* pEvents );
示例已编译验证
/* XRT_API bool xrtHttpServerRouteEvents( xhttpserverrouter* pRouter, xstrview Method, xstrview Pattern, const xhttpserverrouteevents* pEvents ); */ result = xrtHttpServerRouteEvents();
xrtHttpServerRoute
注册只处理完整请求的常用路由。
| 参数 | 说明 |
|---|---|
| xhttpserverrouter* pRouter | 路由器 |
| xstrview Method | HTTP 方法 |
| xstrview Pattern | 模式文本 |
| xhttpserverrouteproc pHandler | 处理器 |
| ptr pData | 用户数据 |
示例已编译验证
/* 注册只处理完整请求的常用路由。 */ result = xrtHttpServerRoute(pRouter, Method, Pattern, pHandler, pData);
xrtHttpServerGet
注册常用 GET 路由;HEAD 自动回退到同一路径的 GET。
| 参数 | 说明 |
|---|---|
| xhttpserverrouter* pRouter | 路由器 |
| xstrview Pattern | 模式文本 |
| xhttpserverrouteproc pHandler | 处理器 |
| ptr pData | 用户数据 |
示例已编译验证
/* 注册常用 GET 路由;HEAD 自动回退到同一路径的 GET。 */ result = xrtHttpServerGet(pRouter, Pattern, pHandler, pData);
xrtHttpServerPost
注册常用 POST 路由。
| 参数 | 说明 |
|---|---|
| xhttpserverrouter* pRouter | 路由器 |
| xstrview Pattern | 模式文本 |
| xhttpserverrouteproc pHandler | 处理器 |
| ptr pData | 用户数据 |
示例已编译验证
/* 注册常用 POST 路由。 */ result = xrtHttpServerPost(pRouter, Pattern, pHandler, pData);
xrtHttpServerPut
注册常用 PUT 路由。
| 参数 | 说明 |
|---|---|
| xhttpserverrouter* pRouter | 路由器 |
| xstrview Pattern | 模式文本 |
| xhttpserverrouteproc pHandler | 处理器 |
| ptr pData | 用户数据 |
示例已编译验证
/* 注册常用 PUT 路由。 */ result = xrtHttpServerPut(pRouter, Pattern, pHandler, pData);
xrtHttpServerPatch
注册常用 PATCH 路由。
| 参数 | 说明 |
|---|---|
| xhttpserverrouter* pRouter | 路由器 |
| xstrview Pattern | 模式文本 |
| xhttpserverrouteproc pHandler | 处理器 |
| ptr pData | 用户数据 |
示例已编译验证
/* 注册常用 PATCH 路由。 */ result = xrtHttpServerPatch(pRouter, Pattern, pHandler, pData);
xrtHttpServerDelete
注册常用 DELETE 路由。
| 参数 | 说明 |
|---|---|
| xhttpserverrouter* pRouter | 路由器 |
| xstrview Pattern | 模式文本 |
| xhttpserverrouteproc pHandler | 处理器 |
| ptr pData | 用户数据 |
示例已编译验证
/* 注册常用 DELETE 路由。 */ result = xrtHttpServerDelete(pRouter, Pattern, pHandler, pData);
xrtHttpServerAny
注册任意合法 HTTP 方法路由。
| 参数 | 说明 |
|---|---|
| xhttpserverrouter* pRouter | 路由器 |
| xstrview Pattern | 模式文本 |
| xhttpserverrouteproc pHandler | 处理器 |
| ptr pData | 用户数据 |
示例已编译验证
/* 注册任意合法 HTTP 方法路由。 */ result = xrtHttpServerAny(pRouter, Pattern, pHandler, pData);
xrtHttpServerRouterFreeze
冻结 Router;成功后可无锁并发分发且不能继续注册。
| 参数 | 说明 |
|---|---|
| xhttpserverrouter* pRouter | 路由器 |
示例已编译验证
xrtHttpServerRouterFreeze(pRouter);
xrtHttpServerRouterFrozen
返回 Router 是否已经冻结。
| 参数 | 说明 |
|---|---|
| const xhttpserverrouter* pRouter | 路由器 |
示例已编译验证
/* 返回 Router 是否已经冻结。 */ result = xrtHttpServerRouterFrozen(pRouter);
xrtHttpServerRouterCount
返回已注册路由数量。
| 参数 | 说明 |
|---|---|
| const xhttpserverrouter* pRouter | 路由器 |
示例已编译验证
/* 返回已注册路由数量。 */ result = xrtHttpServerRouterCount(pRouter);
xrtHttpServerRouterDispatch
对完整请求执行一次分发;未命中时自动响应 404、405 或 OPTIONS。
| 参数 | 说明 |
|---|---|
| const xhttpserverrouter* pRouter | 路由器 |
| xhttpserver* pServer | 服务端对象 |
| xhttpconn* pConnection | 连接对象 |
| const xhttpserverrequest* pRequest | 请求对象 |
示例已编译验证
/* 对完整请求执行一次分发;未命中时自动响应 404、405 或 OPTIONS。 */ result = xrtHttpServerRouterDispatch(pRouter, pServer, pConnection, pRequest);
xrtHttpServerRouterStart
XRT_API xhttpserver* xrtHttpServerRouterStart( xnetengine* pEngine, const xhttpserverconfig* pConfig, xhttpserverrouter* pRouter, const xhttpserverevents* pEvents );
示例已编译验证
/* XRT_API xhttpserver* xrtHttpServerRouterStart( xnetengine* pEngine, const xhttpserverconfig* pConfig, xhttpserverrouter* pRouter, const xhttpserverevents* pEvents ); */ result = xrtHttpServerRouterStart();