-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
57 lines (47 loc) · 1.84 KB
/
Copy pathProgram.cs
File metadata and controls
57 lines (47 loc) · 1.84 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using BlazingStory.Components;
using BlazingStory.McpServer;
using Microsoft.Extensions.DependencyInjection.Extensions;
using ServerApp1.Stories.Components;
using ServerApp1.Stories.Components.Pages;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
var serverUrl = builder.Configuration[WebHostDefaults.ServerUrlsKey]?.Split(';').FirstOrDefault() ?? "http://localhost:5166";
builder.Services.TryAddScoped(sp => new HttpClient { BaseAddress = new Uri(serverUrl) });
builder.Services.AddBlazingStoryMcpServer();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error", createScopeForErrors: true);
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
// Map BlazingStory MCP endpoints on the root URL, as "/mcp/blazingstory".
app.MapBlazingStoryMcp();
// Map the BlazingStory server component to the "/stories" path.
app.Map("/stories", appBuilder =>
{
appBuilder.UseStaticFiles();
appBuilder.UseRouting();
appBuilder.UseAntiforgery();
appBuilder.UseEndpoints(endpoints =>
{
endpoints.MapRazorComponents<BlazingStoryServerComponent<IndexPage, IFramePage>>()
.AddInteractiveServerRenderMode();
});
});
// Map the default app on the root URL.
app.UseStaticFiles();
app.UseRouting();
app.UseAntiforgery();
#pragma warning disable ASP0014 // Suppress ASP0014 because this code intentionally mounts multiple Blazor application entry points.
app.UseEndpoints(endpoints =>
{
endpoints.MapRazorComponents<DefaultApp>()
.AddInteractiveServerRenderMode();
});
#pragma warning restore ASP0014
app.Run();