WebRoute class

Represents a route in the web application, including path configurations, methods, controllers, and authorization details.

The WebRoute class is used to define routes for handling HTTP requests. It allows you to specify the main path, additional paths, HTTP methods, associated controllers, and other details needed for routing and authorization.

Constructors

WebRoute({required String path, required WebRequest rq, List<String> extraPath = const [], List<String> methods = const [RequestMethods.GET], WaController? controller, String widget = "", Future<String> index()?, WaAuthController? auth, List<WebRoute> children = const [], Map<String, Object?> params = const {}, String title = '', List<String> excludePaths = const [], Future<ApiDoc>? apiDoc()?, List<String> permissions = const [], List<String> hosts = const ['*'], List<int> ports = const []})
Creates a WebRoute instance with the specified parameters.

Properties

apiDoc Future<ApiDoc>? Function()?
Function to generate API documentation for this route.
getter/setter pair
auth WaAuthController?
An optional WaAuthController for handling authentication and session checks for this route.
getter/setter pair
children List<WebRoute>
Sub-routes of the current route, defining a tree structure of routes.
getter/setter pair
controller WaController?
The controller associated with this route. This is an instance of WaController that will handle the request for this route.
getter/setter pair
excludePaths List<String>
Paths that should not be included in all sub-paths of /*.
getter/setter pair
extraPath List<String>
Additional main paths for this route. This allows for multiple matching paths.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
hosts List<String>
The primary hostname of the route. for example example.com. by default is it ['*'] to match all hostnames. If using example.com, it will match only the example.com hostname. otherwise, it will match all hostnames that are set.
getter/setter pair
index Future<String> Function()?
A function representing the main controller function to load for this route. This is typically used to render the index of the controller.
getter/setter pair
methods List<String>
List of HTTP methods allowed for this route. For example, POST, GET, HEAD, etc.
getter/setter pair
params Map<String, Object?>
Default variable parameters to use in the content.
getter/setter pair
path String
The primary path of the route. For example, /test or /test/*. If using /test/*, it will match all sub-paths under /test.
getter/setter pair
permissions List<String>
Permissions required for this route. Authentication is needed to use these permissions.
getter/setter pair
ports List<int>
The primary port of the route. for example [8080]. by default is it [] to match all ports. If using [8080], it will match only the 8080 port. otherwise, it will match all ports that are set. and then other ports will be ignored.
getter/setter pair
rq WebRequest
The WebRequest context for the current request.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
title String
The title of the page, which can be used as <?= $e.pageTitle ?>.
getter/setter pair
widget String
Path to the widget to be loaded as content for this route.
getter/setter pair

Methods

allowMethod() bool
Checks if the current HTTP method is allowed for this route.
getPathRender() String
Gets the path after rendering.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setPathRender(String path) → void
Sets the rendered path for this route.
toMap(String parentPath, bool hasAuth, String method) List<Map>
Converts the route to a list of maps representing its details.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

makeList({required List<String> paths, required WebRequest rq, List<String> extraPath = const [], List<String> methods = const [RequestMethods.GET], WaController? controller, Future<String> index()?, WaAuthController? auth, List<String> permissions = const [], String widget = "", Map<String, Object?> params = const {}, String title = "", List<String> excludePaths = const [], List<WebRoute> children = const [], Future<ApiDoc>? apiDoc()?, List<String> hosts = const ['*'], List<int> ports = const []}) List<WebRoute>
Creates a list of WebRoute instances from the given parameters.