Class ApplicationBuilderExtensions
- Namespace
- Codebelt.Extensions.Asp.Versioning
- Assembly
- Codebelt.Extensions.Asp.Versioning.dll
Extension methods for the Microsoft.AspNetCore.Builder.IApplicationBuilder interface.
public static class ApplicationBuilderExtensions
- Inheritance
-
ApplicationBuilderExtensions
Methods
UseRestfulApiVersioning(IApplicationBuilder, Func<HttpContext, HttpStatusCodeException>)
Adds a middleware to the pipeline that will intercept status codes written directly to the response and throw an appropriate HttpStatusCodeException that can then be translated and re-written in a consistent way.
public static IApplicationBuilder UseRestfulApiVersioning(this IApplicationBuilder builder, Func<HttpContext, HttpStatusCodeException> statusCodeExceptionFactory = null)
Parameters
builder
IApplicationBuilderThe type that provides the mechanisms to configure an application’s request pipeline.
statusCodeExceptionFactory
Func<HttpContext, HttpStatusCodeException>The function delegate that will resolve and throw a proper HttpStatusCodeException from status codes written directly to the response.
Returns
- IApplicationBuilder
A reference to this instance after the operation has completed.
Remarks
This method was introduced because of the design decisions made of the author of Asp.Versioning; for more information have a read at https://github.com/dotnet/aspnet-api-versioning/issues/886
Exceptions
- ArgumentNullException
builder
cannot be null.