Skip to content

Commit d326814

Browse files
committed
Add interfaces for providing metadata from route handler types
- IProvideEndpointParameterMetadata - IProvideEndpointResponseMetadata - Contributes to #40646
1 parent 1faca78 commit d326814

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System.Reflection;
5+
6+
namespace Microsoft.AspNetCore.Http;
7+
8+
/// <summary>
9+
/// Indicates that a type provides a static method that returns <see cref="Endpoint"/> metadata when declared as the
10+
/// parameter type of a route handler delegate. The method must be of the form:
11+
/// <code>public static <see cref="IEnumerable{Object}"/> GetMetadata(<see cref="ParameterInfo"/> parameter, <see cref="IServiceProvider"/> services)</code>
12+
/// </summary>
13+
public interface IProvideEndpointParameterMetadata
14+
{
15+
/// <summary>
16+
/// Supplies objects to apply as metadata to the related <see cref="Endpoint"/>.
17+
/// </summary>
18+
/// <param name="parameter">The <see cref="ParameterInfo"/> that represents the parameter to the endpoint's route handler delegate.</param>
19+
/// <param name="services">The application's <see cref="IServiceProvider"/>.</param>
20+
/// <returns>The objects to apply as <see cref="Endpoint"/> metadata.</returns>
21+
public static abstract IEnumerable<object> GetMetadata(ParameterInfo parameter, IServiceProvider services);
22+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
namespace Microsoft.AspNetCore.Http;
5+
6+
/// <summary>
7+
/// Indicates that a type provides a static method that returns <see cref="Endpoint"/> metadata when declared as the
8+
/// returned type of a <see cref="Endpoint"/> route handler delegate. The method must be of the form:
9+
/// <code>public static <see cref="IEnumerable{Object}"/> GetMetadata(<see cref="Endpoint"/> endpoint, <see cref="IServiceProvider"/> services)</code>
10+
/// </summary>
11+
public interface IProvideEndpointResponseMetadata
12+
{
13+
/// <summary>
14+
/// Supplies objects to apply as metadata to the related <see cref="Endpoint"/>.
15+
/// </summary>
16+
/// <param name="endpoint">The <see cref="Endpoint"/> the returned metadata will be applied to.</param>
17+
/// <param name="services">The application's <see cref="IServiceProvider"/>.</param>
18+
/// <returns>The objects to apply as <see cref="Endpoint"/> metadata.</returns>
19+
public static abstract IEnumerable<object> GetMetadata(Endpoint endpoint, IServiceProvider services);
20+
}

src/Http/Http.Extensions/src/PublicAPI.Unshipped.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
#nullable enable
2+
Microsoft.AspNetCore.Http.IProvideEndpointParameterMetadata
3+
Microsoft.AspNetCore.Http.IProvideEndpointParameterMetadata.GetMetadata(System.Reflection.ParameterInfo! parameter, System.IServiceProvider! services) -> System.Collections.Generic.IEnumerable<object!>!
4+
Microsoft.AspNetCore.Http.IProvideEndpointResponseMetadata
5+
Microsoft.AspNetCore.Http.IProvideEndpointResponseMetadata.GetMetadata(Microsoft.AspNetCore.Http.Endpoint! endpoint, System.IServiceProvider! services) -> System.Collections.Generic.IEnumerable<object!>!
26
Microsoft.AspNetCore.Http.RequestDelegateFactoryOptions.RouteHandlerFilterFactories.get -> System.Collections.Generic.IReadOnlyList<System.Func<Microsoft.AspNetCore.Http.RouteHandlerContext!, Microsoft.AspNetCore.Http.RouteHandlerFilterDelegate!, Microsoft.AspNetCore.Http.RouteHandlerFilterDelegate!>!>?
37
Microsoft.AspNetCore.Http.RequestDelegateFactoryOptions.RouteHandlerFilterFactories.init -> void
48
Microsoft.Extensions.DependencyInjection.RouteHandlerJsonServiceExtensions

0 commit comments

Comments
 (0)