-
-
Notifications
You must be signed in to change notification settings - Fork 746
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
Is it possible to use dynamic paths? #906
Comments
I would like to request this feature as well. Some APIs have URLs in the response that can be called for subsequent requests. For example: Request:
Response: {
"next": "/bar/?from=10",
"results": [ { }, { } ]
} In this example the client can get the next results by requesting the URL returned in the To support this scenario, I suggest to introduce a [Get]
Task<Result> Get([Url] string url) |
Need this as well. |
this would be helpful for us too. |
I have a proof of concept for an implementation of this here: https://github.com/GalaxiaGuy/refit/pull/1/files Should the parameter for the path on
|
All was well till long running API endpoints appeared, which is returning another URL to check status after some time. Need this feature. |
Need this also. |
Need this for endpoints with catch-all route templates, e.g. class DocumentsController : Controller {
[HttpGet("{**path}")]
public Task<IActionResult> Download(string path) {
// ...
}
} And then define the API just like so: interface IDocumentsApi {
[Get("/documents/{**path}")]
Task<IApiResponse> Download(string path);
// or
[Get("/documents/{path}")]
Task<IApiResponse> Download([PathUriFormat(UriFormat.Unescaped)] string path);
} |
@mdschweda it actually works with the following
You will only have to ensure first '/' is not part of the path for example with following data {
|
Thanks |
This would be very useful. |
@Paul-N created #1368 which is basically the same ask (possibility of supporting dynamic URLs within Refit's request/response handling and code generation). His suggested approach ( @ChrisPulman I think one of these issues can be marked duplicate - what do you suggest? And regarding implementation, is this something you could help moving forward? |
I am writing a rest client for Azure Durable Functions.
They work with an HTTP endpoint that starts a long-running task, and it immediately returns a JSON response with "follow-up urls".
Example (urls will have dynamic details at runtime):
Now I want to create a rest client for at least the Status Query endpoint and the Terminate endpoint. These endpoints have dynamic urls / querystring parameters.
If I try to supply them like so:
and I use
Uri.PathAndQuery
to supply the relative path + querystring, then I get a runtime error when callingRestService.For<IFunctionApi>("...")
.Refit complains that
{statusQueryUri}
is not of the form of/foo/bar/baz
.How can I dynamically supply the relative part of the url + querystring while still getting the benefits of refit (adding headers, defining methods and return types via an interface)?
Update
@Paul-N created #1368 which is basically the same ask (possibility of supporting dynamic URLs within Refit's request/response handling and code generation).
His suggested approach (
[Url]
attribute following Retrofit's example) looks good to me and he made an implementation for it.The text was updated successfully, but these errors were encountered: