Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,18 @@ public override int GetDestination( HttpContext httpContext )
switch ( apiVersions.Count )
{
case 0:
// 1. version-neutral endpoints take precedence
if ( destinations.TryGetValue( ApiVersion.Neutral, out destination ) )
// 1. IApiVersionSelector cannot be used yet because there are no candidates that an
// aggregated version model can be computed from to select the default API version.
// version-neutral endpoints are still included in these candidates
if ( options.AssumeDefaultVersionWhenUnspecified )
{
return destination;
return rejection.AssumeDefault;
}

// 2. IApiVersionSelector cannot be used yet because there are no candidates that an
// aggregated version model can be computed from to select the 'default' API version
if ( options.AssumeDefaultVersionWhenUnspecified )
// 2. use version-neutral endpoints, if any
if ( destinations.TryGetValue( ApiVersion.Neutral, out destination ) )
{
return rejection.AssumeDefault;
return destination;
}

httpContext.Features.Set( policyFeature );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,18 @@ public void Add( RouteEndpoint endpoint )

public void Add( RouteEndpoint endpoint, ApiVersion apiVersion, ApiVersionMetadata metadata )
{
// use a singleton of all route patterns that version by url segment. this
// is needed to extract the value for selecting a destination in the jump
// table. any matching template will do and every edge should have the
// same list known through the application, which may be zero
// use a singleton of all route patterns that version by url segment. this is needed to extract the value for
// selecting a destination in the jump table. any matching template will do and every edge should have the same
// list known through the application, which may be zero
var key = new EdgeKey( apiVersion, metadata, routePatterns );

Add( ref key, endpoint );

// include version-neutral endpoints when assuming the default so they are also considered when unspecified
if ( unspecifiedAllowed && metadata.IsApiVersionNeutral && apiVersion == ApiVersion.Neutral )
{
Add( ref assumeDefault, endpoint );
}
}

private void Add( ref EdgeKey key, RouteEndpoint endpoint )
Expand Down
Loading