TryParseUri: Parses an Uri into an HttpActionContext. This includes all the information about which action gets called on which controller as well as the parameters for the action method
3: Verify: Verifies that an HttpActionContext indeed points to the action specified by an expression.
Some notes about Postel's law:
Over-parametrization in the URI is not a problem
Order of query parameters is irrelevant in the URI
Optional parameters can be missing in the URI
Permanent redirect routes are followed. This means that old links are verified successfully, if the rest of the application also supports those old links. A RedirectRouteHandler can be used to achieve this. See Ploeh.Hyprlinkr.UnitTest.RedirectRouteHandler for an implementation.
Some more notes:
I am not really happy with the names of the interfaces and the class. Suggestions for better names are welcome.
I am not really happy with the fact that ParseUri throws a generic ArgumentException if an error occurrs. I am also not happy with the way ResourceLinkVerifier.GetActionDescriptor is implemented. Maybe it would be a better idea to switch the implementation around? Make TryParseUri call ParseUri, put that call in a try-catch block and return false if an exception is caught. Still smells... Suggestions are welcome.
Please see discussion on Issue 1: https://github.com/ploeh/Hyprlinkr/issues/1 I implemented three methods:
ParseUri
: CallsTryParseUri
TryParseUri
: Parses an Uri into anHttpActionContext
. This includes all the information about which action gets called on which controller as well as the parameters for the action method 3:Verify
: Verifies that anHttpActionContext
indeed points to the action specified by an expression.Some notes about Postel's law:
RedirectRouteHandler
can be used to achieve this. SeePloeh.Hyprlinkr.UnitTest.RedirectRouteHandler
for an implementation.Some more notes:
ParseUri
throws a genericArgumentException
if an error occurrs. I am also not happy with the wayResourceLinkVerifier.GetActionDescriptor
is implemented. Maybe it would be a better idea to switch the implementation around? MakeTryParseUri
callParseUri
, put that call in a try-catch block and returnfalse
if an exception is caught. Still smells... Suggestions are welcome.