DotNetCoreBaseAPI 1.1.1
dotnet add package DotNetCoreBaseAPI --version 1.1.1
NuGet\Install-Package DotNetCoreBaseAPI -Version 1.1.1
<PackageReference Include="DotNetCoreBaseAPI" Version="1.1.1" />
<PackageVersion Include="DotNetCoreBaseAPI" Version="1.1.1" />
<PackageReference Include="DotNetCoreBaseAPI" />
paket add DotNetCoreBaseAPI --version 1.1.1
#r "nuget: DotNetCoreBaseAPI, 1.1.1"
#:package DotNetCoreBaseAPI@1.1.1
#addin nuget:?package=DotNetCoreBaseAPI&version=1.1.1
#tool nuget:?package=DotNetCoreBaseAPI&version=1.1.1
DotNetCoreBaseAPI
This class library can be used as base api to import various basic configuration for consumer api. It also contains a test consumer api to execute library locally. Dot Net Version: 8.0
This library provides below features.
- Registers different configuration files (appSettings.json) per environement. (Development, Production)
- Provided with specific logger provider (Serilog, NLog, Log4n etc), register logger configuration. (Update in progress...)
- Provides different authentication services based on provided auth provider from consumer apis. (None, Basic, JWT, Token, OAuth)
- Provides SwaggerGen and Swagger UI for consumer api testing
- Provides APiVersioning support if needed.
- Provides Polly retry policies for HttpClient calls from consumer APIs.
- Provides multiple HttpClient registration.
- Provides different types of health checks for consumer apis. Default health check endpoint is "api/health". More details about health check is in instruction below.
Instructions for consumer APIs
Base API Metadata
Provide DotNetCoreBaseAPI.Models.BaseApiConfigurationMetaData as parameter while calling builder.CreateWebApplicationBuilder to provide different services needed for consumer api.
Healthchecks
Provide heath check configurations in consumer's appSettings.json in below format. "HealthChecks":{ "UriGroup":"<Custome uri group url for URi heal check>", "RemoteUris":[ "List of remote uris for remote endpoints health checks" ] }
Logger Configurations
- Add LogFilePath config under Logging in appSettings.json. "Logging": { "LogLevel": { "Default": "Information", "Microsoft": "Warning", "Microsoft.AspNetCore": "Trace", "System": "Error" }, "LogFilePath": "Logs" // ⇐=== This value }
Polly Retry Settings
Add Polly retry settings in Consumer API's appSettings.Json. Refer below as example.
"PollySettings": { "DefaultPolicy": "Immediate", //Single value either from Immediate|Linear|Exponential "RetryCount": "5", //Number of retries "RetryInterval": 3 //In seconds }
In case above settings are not provided by consumer api, default policies configured will be Immediate, Linear and Exponential with retry count as 5 and retry interval as 3 seconds, else all three policies are configured using "RetryCount" and "RetryInterval" values provided.
Above settings are used to decide retry policy to make http calls using "DefaultPolicy".
Consumer Service Registration
- Consumer APIs can implement "IServiceMarker" from base api to automatically register consumer's services to service collection. Refer below sample service creation for automatic registration.
public class MyService : IMyService, IServiceMarker ⇐= base service interface {}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Asp.Versioning.Http (>= 8.1.0)
- Asp.Versioning.Mvc (>= 8.1.0)
- Asp.Versioning.Mvc.ApiExplorer (>= 8.1.0)
- AspNetCore.HealthChecks.SqlServer (>= 9.0.0)
- AspNetCore.HealthChecks.UI (>= 9.0.0)
- AspNetCore.HealthChecks.UI.Client (>= 9.0.0)
- AspNetCore.HealthChecks.UI.InMemory.Storage (>= 9.0.0)
- AspNetCore.HealthChecks.Uris (>= 9.0.0)
- EntityFrameworkCore.SqlServerCompact40 (>= 2.2.0.7)
- Log4Net (>= 3.1.0)
- Microsoft.AspNetCore.Authentication.Facebook (>= 8.0.5)
- Microsoft.AspNetCore.Authentication.Google (>= 8.0.5)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 8.0.6)
- Microsoft.AspNetCore.Authentication.MicrosoftAccount (>= 8.0.5)
- Microsoft.AspNetCore.Authentication.OAuth (>= 2.2.0)
- Microsoft.AspNetCore.Diagnostics (>= 2.3.0)
- Microsoft.AspNetCore.Diagnostics.Abstractions (>= 2.3.0)
- Microsoft.AspNetCore.Diagnostics.HealthChecks (>= 2.2.0)
- Microsoft.EntityFrameworkCore.SqlServer (>= 9.0.6)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 9.0.6)
- Microsoft.Extensions.Logging.Log4Net.AspNetCore (>= 8.0.0)
- NLog (>= 6.0.1)
- NLog.Extensions.Logging (>= 6.0.1)
- NLog.Web.AspNetCore (>= 6.0.1)
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 9.0.4)
- Polly (>= 8.6.1)
- Serilog (>= 3.1.1)
- Serilog.AspNetCore (>= 8.0.1)
- Serilog.Sinks.Console (>= 5.0.1)
- Serilog.Sinks.File (>= 5.0.0)
- Swashbuckle.AspNetCore (>= 6.6.1)
- Swashbuckle.AspNetCore.SwaggerGen (>= 6.6.1)
- Swashbuckle.AspNetCore.SwaggerUI (>= 6.6.1)
- System.IdentityModel.Tokens.Jwt (>= 7.6.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.