Last active
August 29, 2015 14:19
-
-
Save igorkulman/4e6d24d0fedfe8361c6b to your computer and use it in GitHub Desktop.
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
/// <summary> | |
/// Gets response with ETag. Returns empty body if ETag matches (no data changes) | |
/// </summary> | |
/// <param name="data">Data to match with ETag</param> | |
/// <param name="model">Model to return</param> | |
/// <returns>Response</returns> | |
protected Response GetResponseWithEtag(object data, object model) | |
{ | |
string etag = Utils.ComputeHash(data); | |
if (CacheHelpers.ReturnNotModified(etag, null, this.Context)) | |
{ | |
return HttpStatusCode.NotModified; | |
} | |
return Response.AsJson(model).WithHeader("ETag", etag); | |
} |
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
Get["/startlist/{id}"] = parameters => | |
{ | |
var startList = _competitionService.GetStartList((int)parameters.id); | |
var model = new StartListModel() { StartList = startList }; | |
return GetResponseWithEtag(startList, model); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment