翻阅文档,找不到任何东西。
如何在渡槽中创建可选查询参数?
通过将参数包装在大括号中:
@Operation.get()
Future<Response> getAllCities({@Bind.header('x-api-key') String apiKey}) async
{}
这记录在这里:http ://aqueduct.io/docs/http/resource_controller/#optional-bindings
可选绑定文档给出了如何使用可选query string parameters或headers. 但是这样的 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);
}
}