Skip to content

Commit

Permalink
Update with cache expiration using the beta
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnwildermuth committed Jan 19, 2024
1 parent 95b79f6 commit c0053e8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/Apis/DataApi.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Marvin.Cache.Headers;
using Marvin.Cache.Headers.Extensions;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using WilderMinds.MinimalApiDiscovery;
Expand All @@ -9,13 +10,13 @@ public class DataApi : IApi
{
public void Register(IEndpointRouteBuilder builder)
{
var group = builder.MapGroup("/api/data");

group.MapMethods("dumpchanges", new [] { "OPTIONS" }, DumpChanges);
var group = builder.MapGroup("/api/data")
.AddHttpCacheExpiration(maxAge: 1, noStore: true);
;
group.MapMethods("dumpchanges", new[] { "OPTIONS" }, DumpChanges);
group.MapGet("flaky", Flaky);
}

[HttpCacheExpiration(NoStore = true, MaxAge = 1)]
public static IResult Flaky(HttpContext context)
{
var rando = Random.Shared.Next(2);
Expand All @@ -29,7 +30,6 @@ public static IResult Flaky(HttpContext context)
}
}

[HttpCacheExpiration(NoStore = true, MaxAge = 1)]
public static async Task<IResult> DumpChanges(BillingContext context)
{
try
Expand Down
4 changes: 2 additions & 2 deletions src/RestDesign.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

<ItemGroup>
<PackageReference Include="Asp.Versioning.Mvc" Version="8.0.0" />
<PackageReference Include="Bogus" Version="35.3.0" />
<PackageReference Include="Bogus" Version="35.4.0" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.9.0" />
<PackageReference Include="Mapster" Version="7.4.0" />
<PackageReference Include="Marvin.Cache.Headers" Version="7.0.0" />
<PackageReference Include="Marvin.Cache.Headers" Version="7.1.0-beta" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.1" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.6" />
Expand Down

0 comments on commit c0053e8

Please sign in to comment.