Skip to content

SamhammerAG/Samhammer.Web.Common

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Samhammer.Web.Common

This is a collection of tools to make creation of web projects simpler. It provides functionality that can be used in every web API project that is built with ASP.NET Core.

How to add this to your project:

Available Features

Version endpoint

If it is enabled you get an endpoint "/version" and "/api/version" that returns a json with the version number of the entry assembly and the hosting environment.

Add the following to the method Configure of your Startup.cs to enable it:

app.UseVersion();

Ping endpoint

If it is enabled you get an endpoint "/ping" that just returns "OK".

Add the following to the method Configure of your Startup.cs to enable it:

app.UsePing();

HttpClient with self signed certificates

If it is enabled you get an http client that also accepts untrusted certificates.

Add the following extension to your IWebHostBuilder in Program.cs:

.AddUnsignedHttpClient()

Afterwards you can create a specific http client by using the following code:

var client = HttpClientFactory.CreateClient(HttpClientNames.UnsignedHttpClient);

Furthermore you can allow self signed certs for an existing http client with the following block added to your IHttpClientBuilder:

.AddAllowUnsignedPrimaryHandler()

Exception handling

If you don't want to get error messages in your json api you can enable a default exception handler.

Add the following to the method Configure of your Startup.cs to enable it:

app.UseDefaultExceptionHandler();

Contribute

How to publish package

  • Create a tag and let the github action do the publishing for you

About

Common logic you can use in your for .NET Core web projects

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages