Api-Review - put uri complexity in CreatedResult

This commit is contained in:
Ryan Nowak 2015-09-20 19:11:37 -07:00
parent 42017faa21
commit ccb5ead450
2 changed files with 26 additions and 9 deletions

View File

@ -29,6 +29,27 @@ namespace Microsoft.AspNet.Mvc
StatusCode = StatusCodes.Status201Created;
}
/// <summary>
/// Initializes a new instance of the <see cref="CreatedResult"/> class with the values
/// provided.
/// </summary>
/// <param name="location">The location at which the content has been created.</param>
/// <param name="value">The value to format in the entity body.</param>
public CreatedResult([NotNull] Uri location, object value)
: base(value)
{
if (location.IsAbsoluteUri)
{
Location = location.AbsoluteUri;
}
else
{
Location = location.GetComponents(UriComponents.SerializationInfoString, UriFormat.UriEscaped);
}
StatusCode = StatusCodes.Status201Created;
}
/// <summary>
/// Gets or sets the location at which the content has been created.
/// </summary>

View File

@ -941,17 +941,13 @@ namespace Microsoft.AspNet.Mvc
[NonAction]
public virtual CreatedResult Created([NotNull] Uri uri, object value)
{
string location;
if (uri.IsAbsoluteUri)
var disposableValue = value as IDisposable;
if (disposableValue != null)
{
location = uri.AbsoluteUri;
Response.RegisterForDispose(disposableValue);
}
else
{
location = uri.GetComponents(UriComponents.SerializationInfoString, UriFormat.UriEscaped);
}
return Created(location, value);
return new CreatedResult(uri, value);
}
/// <summary>