Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Templates generation #37

Open
andresmoschini opened this issue May 3, 2015 · 3 comments
Open

Templates generation #37

andresmoschini opened this issue May 3, 2015 · 3 comments

Comments

@andresmoschini
Copy link

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}
@ploeh
Copy link
Owner

ploeh commented May 4, 2015

Does this answer your question?

@ploeh ploeh added the question label May 4, 2015
@andresmoschini
Copy link
Author

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.

@ploeh
Copy link
Owner

ploeh commented May 4, 2015

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants