Created
March 6, 2012 14:32
-
-
Save pedroreys/1986568 to your computer and use it in GitHub Desktop.
CreateResponse
This file contains hidden or 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
public class CreateResponse : HttpResponseMessage | |
{ | |
public CreateResponse() | |
{ | |
StatusCode = HttpStatusCode.Created; | |
} | |
public CreateResponse(IApiResource resource) :this() | |
{ | |
var location = new ResourceLocation(); | |
resource.SetLocation(location); | |
Headers.Location = location.Location; | |
} | |
} | |
public class CreateResponse<T> : HttpResponseMessage<T> | |
{ | |
public CreateResponse() : base(HttpStatusCode.Created) | |
{ | |
} | |
public CreateResponse(T resource) : base(resource, HttpStatusCode.Created) | |
{ | |
if (resource is IApiResource) | |
{ | |
var apiResource = resource as IApiResource; | |
var resourceLocation = new ResourceLocation(); | |
apiResource.SetLocation(resourceLocation); | |
Headers.Location = resourceLocation.Location; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment