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;
|
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>
|
/// <summary>
|
||||||
/// Gets or sets the location at which the content has been created.
|
/// Gets or sets the location at which the content has been created.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -941,17 +941,13 @@ namespace Microsoft.AspNet.Mvc
|
||||||
[NonAction]
|
[NonAction]
|
||||||
public virtual CreatedResult Created([NotNull] Uri uri, object value)
|
public virtual CreatedResult Created([NotNull] Uri uri, object value)
|
||||||
{
|
{
|
||||||
string location;
|
var disposableValue = value as IDisposable;
|
||||||
if (uri.IsAbsoluteUri)
|
if (disposableValue != null)
|
||||||
{
|
{
|
||||||
location = uri.AbsoluteUri;
|
Response.RegisterForDispose(disposableValue);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
return new CreatedResult(uri, value);
|
||||||
location = uri.GetComponents(UriComponents.SerializationInfoString, UriFormat.UriEscaped);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Created(location, value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue