registerRoute abstract method

SimApiBase registerRoute(
  1. String route, {
  2. SimApiHttpMethod? method,
  3. bool? haveRouteParameters,
  4. bool? haveQueryParameters,
  5. RouteHandler? handler,
})

Registers a route with optional configuration for handling requests.

  • route: The API route to register.
  • method: Optional. The HTTP method to associate with the route (e.g., GET, POST, PUT, DELETE). If not provided, a default method will be used.
  • haveRouteParameters: Optional. Indicates if the route includes dynamic route parameters (e.g., /items/{id}). Defaults to false.
  • haveQueryParameters: Optional. Indicates if the route includes query parameters. Defaults to false.
  • handler: Optional. A function to handle requests to this route, allowing customization of the response based on request data and query parameters.

This method allows for detailed configuration of a route, including HTTP method, route parameters, and custom request handling.

Implementation

SimApiBase registerRoute(
  String route, {
  SimApiHttpMethod? method,
  bool? haveRouteParameters,
  bool? haveQueryParameters,
  RouteHandler? handler,
});