Went through the documentation, couldn't find any.
How does one make an optional query param in aqueduct?
Went through the documentation, couldn't find any.
How does one make an optional query param in aqueduct?
By wrapping an argument in curly brackets:
@Operation.get()
Future<Response> getAllCities({@Bind.header('x-api-key') String apiKey}) async
{}
This is documented here: http://aqueduct.io/docs/http/resource_controller/#optional-bindings
The optional binding documention gives examples how to use optional query string parameters
or headers
. But what about URL like this //host.com/path/subpath
? Below the simple example:
// 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);
}
}