Fix verbs and versioning

pull/178/head
Daniel Roth 2022-11-06 14:56:01 -08:00 committed by Chet Husk
parent f8878fb5d3
commit 1dd76f7c8e
5 changed files with 5 additions and 3 deletions

View File

@ -15,6 +15,6 @@ public class EpisodesHttpClient : IEpisodesClient
public async Task<Episode> GetEpisodeByIdAsync(Guid episodeId, CancellationToken cancellationToken)
{
return (await _httpClient.GetFromJsonAsync<Episode>($"v1/episodes/{episodeId}", cancellationToken))!;
return (await _httpClient.GetFromJsonAsync<Episode>($"episodes/{episodeId}", cancellationToken))!;
}
}

View File

@ -16,6 +16,7 @@ namespace ListenTogether.Infrastructure
serviceCollection.AddHttpClient<IEpisodesClient, EpisodesHttpClient>(opt =>
{
opt.BaseAddress = new Uri(configuration["NetPodcastApi:BaseAddress"]);
opt.DefaultRequestHeaders.Add("api-version", "1.0");
});
return serviceCollection;

View File

@ -45,6 +45,7 @@ builder.Services.AddApiVersioning(options =>
options.DefaultApiVersion = new ApiVersion(2, 0);
options.ReportApiVersions = true;
options.AssumeDefaultVersionWhenUnspecified = true;
options.ApiVersionReader = new HeaderApiVersionReader("api-version");
});
builder.Services.AddOutputCache();

View File

@ -10,7 +10,7 @@ public static class CategoriesApi
{
public static RouteGroupBuilder MapCategoriesApi(this RouteGroupBuilder group)
{
group.MapPost("/", GetAllCategories).WithName("GetCategories");
group.MapGet("/", GetAllCategories).WithName("GetCategories");
return group;
}

View File

@ -8,7 +8,7 @@ var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.Services.AddHttpClient<PodcastService>(
client => {
client.BaseAddress = new Uri(builder.Configuration["PodcastApi:BaseAddress"]!);
client.DefaultRequestHeaders.Add("api-supported-versions", "1.0,2.0");
client.DefaultRequestHeaders.Add("api-version", "1.0");
});
builder.Services.AddScoped<ThemeInterop>();
builder.Services.AddScoped<IAudioInterop, AudioInterop>();