I create hypermedia links in models returned by a controller, and these links contain not only rel= and href= attributes, but also a method= one, providing an HTTP methods for the given route. To keep DRY, I'd like to avoid passing method names manually as strings in every link constructor. The RouteDescription already contains all required information, and I'd like to use it.
I can collect all named routes in a separate component (what I do right now), but the ResourceLinker already keeps them in AllRoutes member, so it would be nice to reuse it somehow. What about making the AllRoutes member public, or provide a method to retrieve a RouteDescription by a route name?
P.S.
Note that the current implementation of AllRoutes stores all routes, while using only named ones.
It may be also good to change the AllRoutes to a dictionary, for more effective lookups.
I create hypermedia links in models returned by a controller, and these links contain not only
rel=
andhref=
attributes, but also amethod=
one, providing an HTTP methods for the given route. To keep DRY, I'd like to avoid passing method names manually as strings in every link constructor. TheRouteDescription
already contains all required information, and I'd like to use it.I can collect all named routes in a separate component (what I do right now), but the
ResourceLinker
already keeps them inAllRoutes
member, so it would be nice to reuse it somehow. What about making theAllRoutes
member public, or provide a method to retrieve aRouteDescription
by a route name?P.S. Note that the current implementation of AllRoutes stores all routes, while using only named ones. It may be also good to change the AllRoutes to a dictionary, for more effective lookups.