Api-Review - put uri complexity in CreatedResult
This commit is contained in:
parent
42017faa21
commit
ccb5ead450
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Reference in New Issue