class EndpointRouteBuilder
cangjie
public open class EndpointRouteBuilder <: ApplicationBuilder功能:提供端点路由的构建入口。
该构建器用于收集端点数据源,并提供按 HTTP 方法注册路由的便捷 API。
父类型:
成员概览
| 成员 | 功能 |
|---|---|
| init(IServiceProvider) | 创建一个端点路由构建器。 |
| prop dataSources | 返回当前构建器持有的端点数据源列表。 |
| func createApplicationBuilder() | 创建一个共享同一服务提供器的应用程序构建器。 |
init(IServiceProvider)
cangjie
public init(services: IServiceProvider)功能:创建一个端点路由构建器。
参数:
- services: IServiceProvider - 应用程序服务提供器。
prop dataSources
cangjie
public prop dataSources: List<EndpointDataSource>功能:返回当前构建器持有的端点数据源列表。
类型:List<EndpointDataSource>
func createApplicationBuilder()
cangjie
public func createApplicationBuilder(): ApplicationBuilder功能:创建一个共享同一服务提供器的应用程序构建器。
返回值:
- ApplicationBuilder - 新的应用程序构建器实例。
扩展成员
| 成员 | 功能 |
|---|---|
| func mapGet(String, RequestDelegate) | 注册一个仅响应 GET 请求的路由端点。 |
| func mapPut(String, RequestDelegate) | 注册一个仅响应 PUT 请求的路由端点。 |
| func mapPatch(String, RequestDelegate) | 注册一个仅响应 PATCH 请求的路由端点。 |
| func mapPost(String, RequestDelegate) | 注册一个仅响应 POST 请求的路由端点。 |
| func mapDelete(String, RequestDelegate) | 注册一个仅响应 DELETE 请求的路由端点。 |
| func map(String, RequestDelegate) | 注册一个不限制 HTTP 方法的路由端点。 |
| func mapGroup(String) | 创建一个使用字符串前缀的路由分组。 |
| func mapGroup(RoutePattern) | 创建一个使用路由模式前缀的路由分组。 |
func mapGet(String, RequestDelegate)
cangjie
public func mapGet(pattern: String, delegate: RequestDelegate): RouteHandlerBuilder功能:注册一个仅响应 GET 请求的路由端点。
参数:
- pattern:
String- 路由模板。 - delegate:
RequestDelegate- 请求处理委托。
返回值:
- RouteHandlerBuilder - 可继续配置端点约定的构建器。
func mapPut(String, RequestDelegate)
cangjie
public func mapPut(pattern: String, delegate: RequestDelegate): RouteHandlerBuilder功能:注册一个仅响应 PUT 请求的路由端点。
参数:
- pattern:
String- 路由模板。 - delegate:
RequestDelegate- 请求处理委托。
返回值:
- RouteHandlerBuilder - 可继续配置端点约定的构建器。
func mapPatch(String, RequestDelegate)
cangjie
public func mapPatch(pattern: String, delegate: RequestDelegate): RouteHandlerBuilder功能:注册一个仅响应 PATCH 请求的路由端点。
参数:
- pattern:
String- 路由模板。 - delegate:
RequestDelegate- 请求处理委托。
返回值:
- RouteHandlerBuilder - 可继续配置端点约定的构建器。
func mapPost(String, RequestDelegate)
cangjie
public func mapPost(pattern: String, delegate: RequestDelegate): RouteHandlerBuilder功能:注册一个仅响应 POST 请求的路由端点。
参数:
- pattern:
String- 路由模板。 - delegate:
RequestDelegate- 请求处理委托。
返回值:
- RouteHandlerBuilder - 可继续配置端点约定的构建器。
func mapDelete(String, RequestDelegate)
cangjie
public func mapDelete(pattern: String, delegate: RequestDelegate): RouteHandlerBuilder功能:注册一个仅响应 DELETE 请求的路由端点。
参数:
- pattern:
String- 路由模板。 - delegate:
RequestDelegate- 请求处理委托。
返回值:
- RouteHandlerBuilder - 可继续配置端点约定的构建器。
func map(String, RequestDelegate)
cangjie
public func map(pattern: String, delegate: RequestDelegate): RouteHandlerBuilder功能:注册一个不限制 HTTP 方法的路由端点。
参数:
- pattern:
String- 路由模板。 - delegate:
RequestDelegate- 请求处理委托。
返回值:
- RouteHandlerBuilder - 可继续配置端点约定的构建器。
func mapGroup(String)
cangjie
public func mapGroup(prefix: String): RouteGroupBuilder功能:创建一个使用字符串前缀的路由分组。
组内所有端点的路由模式都会自动追加该前缀,并可继续注册分组级约定。
参数:
- prefix:
String- 路由分组前缀。
返回值:
- RouteGroupBuilder - 对应的路由分组构建器。
func mapGroup(RoutePattern)
cangjie
public func mapGroup(prefix: RoutePattern): RouteGroupBuilder功能:创建一个使用路由模式前缀的路由分组。
参数:
- prefix: RoutePattern - 路由分组前缀模式。
返回值:
- RouteGroupBuilder - 对应的路由分组构建器。