可选的查询参数 aqueduct
Optional query params aqueduct
遍历 documentation,找不到。
如何在 aqueduct 中创建一个可选的查询参数?
通过将参数括在大括号中:
@Operation.get()
Future<Response> getAllCities({@Bind.header('x-api-key') String apiKey}) async
{}
这在此处记录:http://aqueduct.io/docs/http/resource_controller/#optional-bindings
optional binding documention 给出了如何使用可选 query string parameters
或 headers
的示例。但是像这样 //host.com/path/subpath
的 URL 呢?下面是简单的例子:
// 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);
}
}
遍历 documentation,找不到。
如何在 aqueduct 中创建一个可选的查询参数?
通过将参数括在大括号中:
@Operation.get()
Future<Response> getAllCities({@Bind.header('x-api-key') String apiKey}) async
{}
这在此处记录:http://aqueduct.io/docs/http/resource_controller/#optional-bindings
optional binding documention 给出了如何使用可选 query string parameters
或 headers
的示例。但是像这样 //host.com/path/subpath
的 URL 呢?下面是简单的例子:
// 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);
}
}