Hyprlinkr
Hyprlinkr copied to clipboard
Templates generation
Do you think that it is possible to generate link templates or do you have any suggestion about how to extend it to support them?
For example:
var uri = linker.GetUri<FooController>(r => r.GetById(linker.Template("myid")));
to generate
http://localhost/api/foo/{myid}
Or
var uri = linker.GetUri<FooController>(r => r.GetById(linker.Template));
to generate
http://localhost/api/foo/{id}
Does this answer your question?
Hehe, yes, it answer my question. Thanks.
Anyway, I think that it would be great to autogenerate the templates or support it for parameters with different types than string.
Thanks again.
It might be valuable to do something like that. To be honest, I never really though much about this, as I found modelling template parameters as strings a fair compromise (since everything that goes into an URL is ultimately a string anyway). However, I can understand if other people would want it with support for stronger types, like e.g. int
.
The suggested API might be one way to go about it. It looks reminiscent of Moq's It.IsAny<T>()
API.
A proper implementation should use the UriTemplate class for the binding implementation.