forked from dotnet/docs-aspire
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
31 lines (25 loc) · 1.04 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
var builder = DistributedApplication.CreateBuilder(args);
var cache = builder.AddRedis("cache");
var apiCacheInvalidationKey = builder.AddParameter("ApiCacheInvalidationKey", secret: true);
var api = builder.AddProject<Projects.AspireApp_Api>("api")
.WithReference(cache)
.WaitFor(cache)
.WithEnvironment("ApiCacheInvalidationKey", apiCacheInvalidationKey)
.WithHttpCommand(
path: "/cache/invalidate",
displayName: "Invalidate cache",
commandOptions: new HttpCommandOptions()
{
Description = """
Invalidates the API cache. All cached values are cleared!
""",
PrepareRequest = (context) =>
{
var key = apiCacheInvalidationKey.Resource.Value;
context.Request.Headers.Add("X-CacheInvalidation-Key", $"Key: {key}");
return Task.CompletedTask;
},
IconName = "DocumentLightning",
IsHighlighted = true
});
builder.Build().Run();