The Dart SDK is currently in experimental status. If you would like to provide feedback, please reach out to us with your suggestions and comments on our Discord.
Dart - api.route()
Creates a new route (path) within an API.
import 'package:nitric_sdk/nitric.dart';
final customersRoute = Nitric.api("public").route("/customers");
Parameters
- Name
match
- Required
- Required
- Type
- String
- Description
The path matcher to use for this route. Calling
route
on the same API more than once with the same matcher will return the same route object. Matchers accept path parameters in the form of a colon prefixed string. The string provided will be used as that path parameter's name when calling middleware and handlers.
Examples
Create a route
import 'package:nitric_sdk/nitric.dart';
final customersRoute = Nitric.api("public").route("/customers");
Create a route with path params
Route paths can include dynamic parameters. These values will automatically be parsed and provided in the context object for your middleware and handlers as a string
.
For example, if you have a customers path and you want to include a customerId
param you would define the route like this.
import 'package:nitric_sdk/nitric.dart';
final customersRoute = Nitric.api("public").route("/customers/:customerId");