BasePath attribute #1627
Closed
aleksander-ivanov
started this conversation in
General
Replies: 1 comment
-
|
Refit has no [BasePath] attribute like RestEase. The base path comes from the HttpClient.BaseAddress, and Refit does honour the path portion of it. So set the common prefix on the client: // DI
builder.Services.AddRefitClient<IMyApi>()
.ConfigureHttpClient(c => c.BaseAddress = new Uri("https://api.example.com/v1/"));
// or manual
var client = new HttpClient { BaseAddress = new Uri("https://api.example.com/v1/") };
var api = RestService.For<IMyApi>(client);Then your method paths are relative to that: [Get("/users/{id}")] // resolves under /v1
Task<User> GetUser(int id);Notes:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Does Refit has [BasePath] attribute RestEase analogy?
Beta Was this translation helpful? Give feedback.
All reactions