-
Notifications
You must be signed in to change notification settings - Fork 707
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Return 400 instead of 404 for action that can match in at least one A…
- Loading branch information
1 parent
239ec61
commit 144ed88
Showing
5 changed files
with
111 additions
and
7 deletions.
There are no files selected for viewing
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
35 changes: 35 additions & 0 deletions
35
src/Microsoft.AspNet.WebApi.Versioning/Controllers/AggregatedActionMapping.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,35 @@ | ||
namespace Microsoft.Web.Http.Controllers | ||
{ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Diagnostics.Contracts; | ||
using System.Linq; | ||
using System.Web.Http.Controllers; | ||
|
||
/// <content> | ||
/// Provides additional content for the <see cref="ApiVersionActionSelector"/> class. | ||
/// </content> | ||
public partial class ApiVersionActionSelector | ||
{ | ||
private sealed class AggregatedActionMapping : ILookup<string, HttpActionDescriptor> | ||
{ | ||
private readonly IReadOnlyList<ILookup<string, HttpActionDescriptor>> actionMappings; | ||
|
||
internal AggregatedActionMapping( IReadOnlyList<ILookup<string, HttpActionDescriptor>> actionMappings ) | ||
{ | ||
Contract.Requires( actionMappings != null ); | ||
this.actionMappings = actionMappings; | ||
} | ||
|
||
public IEnumerable<HttpActionDescriptor> this[string key] => actionMappings.Where( am => am.Contains( key ) ).SelectMany( am => am[key] ); | ||
|
||
public int Count => actionMappings[0].Count; | ||
|
||
public bool Contains( string key ) => actionMappings.Any( am => am.Contains( key ) ); | ||
|
||
public IEnumerator<IGrouping<string, HttpActionDescriptor>> GetEnumerator() => actionMappings[0].GetEnumerator(); | ||
|
||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); | ||
} | ||
} | ||
} |
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