-
Notifications
You must be signed in to change notification settings - Fork 3
/
ApplicationBuilderExtensions.cs
71 lines (66 loc) · 4.75 KB
/
ApplicationBuilderExtensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using System;
using Cuemon.AspNetCore.Builder;
using Cuemon.AspNetCore.Http.Headers;
using Microsoft.AspNetCore.Builder;
namespace Cuemon.Extensions.AspNetCore.Http.Headers
{
/// <summary>
/// Extension methods for the <see cref="IApplicationBuilder"/> interface.
/// </summary>
public static class ApplicationBuilderExtensions
{
/// <summary>
/// Adds a correlation identifier HTTP header to the <see cref="IApplicationBuilder"/> request execution pipeline.
/// </summary>
/// <param name="builder">The type that provides the mechanisms to configure an application’s request pipeline.</param>
/// <param name="setup">The <see cref="CorrelationIdentifierOptions"/> middleware which may be configured.</param>
/// <returns>An <see cref="IApplicationBuilder"/> that can be used to further configure the request pipeline.</returns>
/// <remarks>Default HTTP header name is <c>X-Correlation-ID</c>.</remarks>
public static IApplicationBuilder UseCorrelationIdentifier(this IApplicationBuilder builder, Action<CorrelationIdentifierOptions> setup = null)
{
return MiddlewareBuilderFactory.UseConfigurableMiddleware<CorrelationIdentifierMiddleware, CorrelationIdentifierOptions>(builder, setup);
}
/// <summary>
/// Adds a request identifier HTTP header to the <see cref="IApplicationBuilder"/> request execution pipeline.
/// </summary>
/// <param name="builder">The type that provides the mechanisms to configure an application’s request pipeline.</param>
/// <param name="setup">The <see cref="RequestIdentifierOptions"/> middleware which may be configured.</param>
/// <returns>An <see cref="IApplicationBuilder"/> that can be used to further configure the request pipeline.</returns>
/// <remarks>Default HTTP header name is <c>X-Request-ID</c>.</remarks>
public static IApplicationBuilder UseRequestIdentifier(this IApplicationBuilder builder, Action<RequestIdentifierOptions> setup = null)
{
return MiddlewareBuilderFactory.UseConfigurableMiddleware<RequestIdentifierMiddleware, RequestIdentifierOptions>(builder, setup);
}
/// <summary>
/// Adds a HTTP User-Agent header parser to the <see cref="IApplicationBuilder"/> request execution pipeline.
/// </summary>
/// <param name="builder">The type that provides the mechanisms to configure an application’s request pipeline.</param>
/// <param name="setup">The <see cref="UserAgentSentinelOptions"/> middleware which may be configured.</param>
/// <returns>An <see cref="IApplicationBuilder"/> that can be used to further configure the request pipeline.</returns>
public static IApplicationBuilder UseUserAgentSentinel(this IApplicationBuilder builder, Action<UserAgentSentinelOptions> setup = null)
{
return MiddlewareBuilderFactory.UseConfigurableMiddleware<UserAgentSentinelMiddleware, UserAgentSentinelOptions>(builder, setup);
}
/// <summary>
/// Adds an API key header parser to the <see cref="IApplicationBuilder"/> request execution pipeline.
/// </summary>
/// <param name="builder">The type that provides the mechanisms to configure an application’s request pipeline.</param>
/// <param name="setup">The <see cref="ApiKeySentinelOptions"/> middleware which may be configured.</param>
/// <returns>An <see cref="IApplicationBuilder"/> that can be used to further configure the request pipeline.</returns>
public static IApplicationBuilder UseApiKeySentinel(this IApplicationBuilder builder, Action<ApiKeySentinelOptions> setup = null)
{
return MiddlewareBuilderFactory.UseConfigurableMiddleware<ApiKeySentinelMiddleware, ApiKeySentinelOptions>(builder, setup);
}
/// <summary>
/// Adds an HTTP Cache-Control and HTTP Expires header to the <see cref="IApplicationBuilder"/> request execution pipeline.
/// </summary>
/// <param name="builder">The type that provides the mechanisms to configure an application’s request pipeline.</param>
/// <param name="setup">The <see cref="CacheableOptions"/> middleware which may be configured.</param>
/// <returns>An <see cref="IApplicationBuilder"/> that can be used to further configure the request pipeline.</returns>
/// <returns>An <see cref="IApplicationBuilder"/> that can be used to further configure the request pipeline.</returns>
public static IApplicationBuilder UseCacheControl(this IApplicationBuilder builder, Action<CacheableOptions> setup = null)
{
return MiddlewareBuilderFactory.UseConfigurableMiddleware<CacheableMiddleware, CacheableOptions>(builder, setup);
}
}
}