-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
593 changed files
with
22,810 additions
and
9,485 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"sdk": { | ||
"version": "8.0.300" | ||
"version": "8.0.300", | ||
"rollForward": "latestFeature" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/Indice.AspNetCore.Builder/Indice.AspNetCore.Builder.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup Label="Package"> | ||
<PackageTags>AspNetCore;WebApplicationBuilder</PackageTags> | ||
<PackageReleaseNotes>Create preconfigured minimal api Builder.</PackageReleaseNotes> | ||
<VersionPrefix>$(VersionPrefixAspNet)</VersionPrefix> | ||
<TargetFrameworks>net8.0</TargetFrameworks> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<FrameworkReference Include="Microsoft.AspNetCore.App" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Indice.AspNetCore" Version="$(VersionPrefixCore)" /> | ||
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.7.0" /> | ||
<PackageReference Include="Azure.Monitor.OpenTelemetry.AspNetCore" Version="1.2.0" /> | ||
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.9.0" /> | ||
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.9.0" /> | ||
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.9.0" /> | ||
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.9.0" /> | ||
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.9.0" /> | ||
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.9.0" /> | ||
<PackageReference Include="OpenTelemetry.Resources.Container" Version="1.0.0-beta.9" /> | ||
<PackageReference Include="IdentityModel.AspNetCore.OAuth2Introspection" Version="6.2.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'"> | ||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.7" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Indice.AspNetCore\Indice.AspNetCore.csproj" /> | ||
</ItemGroup> | ||
</Project> |
97 changes: 97 additions & 0 deletions
97
src/Indice.AspNetCore.Builder/IndiceWebApplicationBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
using Indice.AspNetCore.Middleware; | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Rewrite; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Diagnostics.Metrics; | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Microsoft.AspNetCore.Builder; | ||
|
||
/// <summary> | ||
/// A builder for web applications and services that has all the indice defaults preconfigured. This is a decorator for the inner <seealso cref="WebApplicationBuilder"/> | ||
/// </summary> | ||
public class IndiceWebApplicationBuilder : IHostApplicationBuilder | ||
{ | ||
private WebApplicationBuilder InnerBuilder { get; } | ||
|
||
/// <summary> | ||
/// constructs the <see cref="IndiceWebApplicationBuilder "/> given the inner builder. | ||
/// </summary> | ||
/// <param name="innerBuilder"></param> | ||
internal IndiceWebApplicationBuilder(WebApplicationBuilder innerBuilder) { | ||
InnerBuilder = innerBuilder; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public IConfigurationManager Configuration => InnerBuilder.Configuration; | ||
|
||
/// <inheritdoc/> | ||
public IHostEnvironment Environment => InnerBuilder.Environment; | ||
|
||
/// <inheritdoc/> | ||
public ILoggingBuilder Logging => InnerBuilder.Logging; | ||
|
||
/// <inheritdoc/> | ||
public IMetricsBuilder Metrics => InnerBuilder.Metrics; | ||
|
||
/// <inheritdoc/> | ||
IDictionary<object, object> IHostApplicationBuilder.Properties => ((IHostApplicationBuilder)InnerBuilder).Properties; | ||
|
||
/// <inheritdoc/> | ||
public IServiceCollection Services => InnerBuilder.Services; | ||
|
||
/// <inheritdoc/> | ||
void IHostApplicationBuilder.ConfigureContainer<TContainerBuilder>(IServiceProviderFactory<TContainerBuilder> factory, Action<TContainerBuilder>? configure) => | ||
((IHostApplicationBuilder)InnerBuilder).ConfigureContainer(factory, configure); | ||
|
||
/// <summary> | ||
/// Builds the <see cref="WebApplication"/>. | ||
/// </summary> | ||
/// <returns>A configured <see cref="WebApplication"/>.</returns> | ||
public WebApplication BuildDefault() => InnerBuilder.Build(); | ||
|
||
/// <summary> | ||
/// Builds the <see cref="WebApplication"/> to the idice specifications. | ||
/// </summary> | ||
/// <returns>A configured <see cref="WebApplication"/>.</returns> | ||
public WebApplication Build() { | ||
var app = InnerBuilder.Build(); | ||
|
||
if (app.Configuration.ProxyEnabled()) { | ||
app.UseForwardedHeaders(); | ||
app.UseHttpMethodOverride(); | ||
} | ||
|
||
app.UseExceptionHandler(); | ||
app.UseStatusCodePages(); | ||
app.UseAuthentication(); | ||
app.UseAuthorization(); | ||
if (app.Environment.IsDevelopment()) { | ||
app.UseDeveloperExceptionPage(); | ||
} | ||
if (app.Configuration.UseRedirectToHost()) { | ||
var rewrite = new RewriteOptions(); | ||
rewrite.Rules.Add(new RedirectToHostRewriteRule(app.Configuration.GetHost())); | ||
app.UseRewriter(rewrite); | ||
} | ||
if (app.Configuration.UseHttpsRedirection()) { | ||
app.UseHttpsRedirection(); | ||
} | ||
if (app.Configuration.HstsEnabled()) { | ||
app.UseHsts(); | ||
} | ||
app.UseRequestLocalization(); | ||
app.UseCors(); | ||
return app; | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="WebApplication"/> class with preconfigured defaults. | ||
/// </summary> | ||
/// <param name="args">The command line arguments.</param> | ||
/// <returns>The <see cref="WebApplication"/>.</returns> | ||
public static IndiceWebApplicationBuilder CreateBuilder(string[] args) => | ||
new(WebApplication.CreateBuilder(args).AddMinimalApiDefaults()); | ||
} |
Oops, something went wrong.