Skip to content

Commit

Permalink
feat: add regex route constraint to automatically support WebApplicat…
Browse files Browse the repository at this point in the history
…on.CreateSlimBuilder (#94)

Adds support for WebApplicaton.CreateSlimBuilder by configuring the regex route options on AddBlazorReports
  • Loading branch information
gabynevada authored May 22, 2024
1 parent b54212c commit dd741ca
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/SimpleReportServer/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using BlazorReports.Extensions;
using SimpleReportServer;

var builder = WebApplication.CreateBuilder(args);
var builder = WebApplication.CreateSlimBuilder(args);

builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
Expand Down
2 changes: 1 addition & 1 deletion examples/SimpleReportServer/SimpleReportServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.5" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 6 additions & 0 deletions src/BlazorReports/Extensions/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using BlazorReports.Services;
using BlazorReports.Services.BrowserServices;
using BlazorReports.Services.BrowserServices.Factories;
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.Routing.Constraints;
using Microsoft.Extensions.DependencyInjection;

namespace BlazorReports.Extensions;
Expand Down Expand Up @@ -30,6 +32,10 @@ public static IServiceCollection AddBlazorReports(
services.AddSingleton<IBrowserService, BrowserService>();
services.AddSingleton<IReportService, ReportService>();

services.Configure<RouteOptions>(routeOptions =>
routeOptions.SetParameterPolicy<RegexInlineRouteConstraint>("regex")
);

return services;
}
}

0 comments on commit dd741ca

Please sign in to comment.