Aqueduct 可选查询参数导水管

Aqueduct 可选查询参数导水管,aqueduct,Aqueduct,查了一遍,没找到 如何在渡槽中创建可选查询参数?将参数括在花括号中: @Operation.get() Future<Response> getAllCities({@Bind.header('x-api-key') String apiKey}) async {} @Operation.get() 未来的getAllCities({@Bind.header('x-api-key')字符串apiKey})异步 {} 这在这里有文档记录:示例给出了如何使用可选的查询字符串参数或标

查了一遍,没找到


如何在渡槽中创建可选查询参数?

将参数括在花括号中:

@Operation.get()
Future<Response> getAllCities({@Bind.header('x-api-key') String apiKey}) async 
{}
@Operation.get()
未来的getAllCities({@Bind.header('x-api-key')字符串apiKey})异步
{}
这在这里有文档记录:

示例给出了如何使用可选的
查询字符串参数
标题
。但是像这样的URL呢
//host.com/path/subpath
?下面是一个简单的例子:

// Dummy example class
class OptionalController extends ResourceController {
  @Operation.get()
  Future<Response> getItemsByDefault() => getItemsByCount(1);

  @Operation.get('count')
  Future<Response> getItemsByCount(@Bind.path('count') int count) async {
     return Response.ok(count);
  }
}
//虚拟示例类
类OptionalController扩展ResourceController{
@get()操作
Future getItemsByDefault()=>getItemsByCount(1);
@操作。get('count')
未来的getItemsByCount(@Bind.path('count')int count)异步{
返回响应。ok(计数);
}
}

我认为你给我看的链接的整个部分(我已经在那里浏览了一百万次)应该被你的第一句话所取代。这就是关于可选绑定的全部内容。非常感谢。