shelf_rest.extend library

The shelf_rest.extend library.

shelf_rest package is an extension of shelf_route, which is itself also extensible.

For example mojito extends the shelf_rest Router to add several helper methods.

Consult the shelf_route documentation for more information


Annotation corresponding to the add method of Router For example, the following [...]
Annotation corresponding to the addAll method of Router For example, the following [...]
Representation of a content type. An instance of ContentType is immutable.
The default implementation of Route. This is the most common kind of Route and is the basis of the core builders. Routing is done using the associated DefaultSegmentRouter which routes on the Request path and method
The default implementation of RequestRouter.
DefaultRouterBuilder<B extends DefaultRouterBuilder>
A SpecBasedRouterBuilder that defines a simple API for creating routes
The default implementation of SegmentRouter that routes based on the Request path and http methods
The default implementation of SimpleRoute.
Annotation corresponding to the delete method of Router For example, the following [...]
Annotation corresponding to the get method of Router For example, the following [...]
LinksBuilder<L extends Links>
A HandlerAdapter that can be merged with another handlerAdapter of the same type
Annotation corresponding to the post method of Router For example, the following [...]
Annotation corresponding to the put method of Router For example, the following [...]
An annotation that indicates that a parameter should be bound to the request body. The body will be parsed into an object of the specified type. [...]
RequestRouter<R extends Route>
A Route that routes by attempting to route to a list of child Routes in order. The first Route that handles the request wins. [...]
An annotation on a class method that indicates it is a particular standard resource operation. This can be used to override the default naming scheme and HTTP method for operations on a RestResource as well as to customise the operation with custom Middleware.
ResourceModel<R extends Jsonable>
Annotation to tweak default creating of responses
A class to identify the standard RestResource operations
Class Annotation to indicate a REST resource with a given pathParameterName. REST resources typically follow a common pattern for the standard operations. For example a Books resource might look like [...]
The root of the Router hierarchy. A Route is something capable of routing a Request. [...]
Routeable<R extends Router>
A class capable of creating routes in a given Router. In most cases RouteableFunction is simpler and more compact
RouteAdapter<R extends DefaultRoute>
An adapter that converts a RouteSpec into a Route. The combination of pairs of RouteSpecs and their RouteAdapters provides a lot of flexibility in the creation of Routes
Base class for all annotations that mimic the methods on Router. These support all the features for the corresponding methods and are therefore a complete alternative way to express the same
Router<B extends Router>
A router builder for shelf_rest
An adapter that adapts an external form of a Router into an object of type Router. This allows other libraries to extend shelf_route
RouterBuilder<R extends RequestRouter>
The base of all builders for RequestRouters
Provides the data that will be used to create a RequestRouter. The routeAdapter if provided will be combined with existing adapters in the router and the result used to adapt the definition into a Router. routes must only contain objects of type RouterDefinition and SimpleRouteSpec
RouteSpec<R extends DefaultRoute>
An abstract specification of a Route. A RouteSpec requires a matching RouteAdapter to turn it into a Route. [...]
Visitor pattern support
Provides contextual information about the routing process. In particular it provides access to the currentRoute the request is passing through and to the path through the router hierarchy that the request has so far traveled (via routingBreadCrumbs)
SearchResourceModel<R extends Jsonable>
ShelfRestRouterBuilder<B extends ShelfRestRouterBuilder>
A leaf node in the hierarchy. A SimpleRoute will route by checking if the Request matches the conditions for the route and if so handling the request directly [...]
An adapter that adapts an external form of a SimpleRoute into an object of type SimpleRoute. This allows other libraries to extend shelf_route
Provides the data that will be used to create a SimpleRoute. The routeAdapter if provided will be combined with existing adapters in the router and the result used to adapt the spec into a SimpleRoute. This includes adapting the handler into a Handler, the path into a UriPattern plus including any provided Middleware
SpecBasedRouterBuilder<B extends DefaultRouterBuilder>
a RouterBuilder that uses pairs of RouteSpec and RouteAdapter to define routes in an abstract, extensible way


ALL_METHODS → const dynamic
Used to specify that the Router should route requests to all HTTP methods for a given route


allMethods → Set<String>


appendToRoutingBreadCrumbs(Map context, Route route) RoutingContext
getPathParameter(Request request, String parameterName) → Object
Fetches a single path parameter from the given request with the given parameterName
getPathParameters(Request request) → Map<String, Object>
Fetches all the path parameters from the given request
getRoutingContext(Request request) → Option<RoutingContext>
Retrieves the current RoutingContext for the given Request or None
noopHandlerAdapter(Handler handler) → Handler
a HandlerAdapter that does nothing
noopRouteableAdapter(RouteableFunction routeable) RouteableFunction
a RouteableFunction that does nothing
printRoutes(Router<Router> router, { Printer printer: print }) → void
prints out a representation of all the routes within the router, using the printer if provided or the standard Dart print function if not.
router({dynamic path, String name, HandlerAdapter handlerAdapter, RouteableAdapter routeableAdapter, PathAdapter pathAdapter: r.uriTemplatePattern, Function fallbackHandler, Middleware middleware }) Router<Router>
Creates a shelf_rest router builder. [...]


HandlerAdapter(Function handler) → Handler
a function that adapts a function to be a shelf Handler
IdExtractor(dynamic model) → dynamic
PathAdapter(dynamic path) → UriPattern
a function that adapts some representation of a path into the form UriPattern that is used internally
Printer(String s) → void
ResourceLinksFactoryFunction(dynamic resourceId, { bool includeSelf }) ResourceLinks
RouteableAdapter(Function handler) RouteableFunction
a function that adapts a function to be a RouteableFunction
RouteableFunction(DefaultRouterBuilder<DefaultRouterBuilder> router) → dynamic
A function capable of creating routes in a given Router

Exceptions / Errors

Thrown by a RequestRouter if no routes match the request