-
Notifications
You must be signed in to change notification settings - Fork 708
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added IEndpointInspector so that controller action endpoints are not …
…processed by min api endpoint collators. Related #1066
- Loading branch information
1 parent
1c13628
commit 9d18108
Showing
8 changed files
with
112 additions
and
22 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
src/AspNetCore/WebApi/src/Asp.Versioning.Http/ApiExplorer/DefaultEndpointInspector.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
|
||
namespace Asp.Versioning.ApiExplorer; | ||
|
||
using Microsoft.AspNetCore.Http; | ||
|
||
/// <summary> | ||
/// Represents the default <see cref="IEndpointInspector">endpoint inspector</see>. | ||
/// </summary> | ||
[CLSCompliant(false)] | ||
public sealed class DefaultEndpointInspector : IEndpointInspector | ||
{ | ||
/// <inheritdoc /> | ||
public bool IsControllerAction( Endpoint endpoint ) => false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/AspNetCore/WebApi/src/Asp.Versioning.Http/ApiExplorer/IEndpointInspector.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
|
||
namespace Asp.Versioning.ApiExplorer; | ||
|
||
using Microsoft.AspNetCore.Http; | ||
|
||
/// <summary> | ||
/// Defines the behavior of an endpoint inspector. | ||
/// </summary> | ||
[CLSCompliant( false )] | ||
public interface IEndpointInspector | ||
{ | ||
/// <summary> | ||
/// Determines whether the specified endpoint is a controller action. | ||
/// </summary> | ||
/// <param name="endpoint">The <see cref="Endpoint">endpoint</see> to inspect.</param> | ||
/// <returns>True if the <paramref name="endpoint"/> is for a controller action; otherwise, false.</returns> | ||
bool IsControllerAction( Endpoint endpoint ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/AspNetCore/WebApi/src/Asp.Versioning.Mvc/ApiExplorer/MvcEndpointInspector.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
|
||
namespace Asp.Versioning.ApiExplorer; | ||
|
||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
/// <summary> | ||
/// Represents the <see cref="IEndpointInspector">inspector</see> that understands | ||
/// <see cref="Endpoint">endpoints</see> defined by MVC controllers. | ||
/// </summary> | ||
[CLSCompliant(false)] | ||
public sealed class MvcEndpointInspector : IEndpointInspector | ||
{ | ||
/// <inheritdoc /> | ||
public bool IsControllerAction( Endpoint endpoint ) | ||
{ | ||
ArgumentNullException.ThrowIfNull( endpoint ); | ||
return endpoint.Metadata.Any( static attribute => attribute is ControllerAttribute ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters