using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Web; using Nancy; namespace Sony.Filtr.API.Nancy.Extensions { public static class ResponseExtensions { public static Response WithLastModified(this Response response, DateTime lastModified) { if (response.Headers == null) { response.Headers = new Dictionary(); } if (lastModified != DateTime.MaxValue && lastModified != DateTime.MinValue) { response.Headers["Last-Modified"] = lastModified.ToString("R"); } return response; } public static Response WithFastlyKey(this Response response, params string[] keys) { if (response.Headers == null) { response.Headers = new Dictionary(); } response.Headers["Surrogate-Key"] = string.Join(" ", keys); return response; } public static Response WithCacheHeaders(this Response response, Cachable cachable, TimeSpan maxAge, int? staleWhileRevalidate = null, int? staleIfError = null) { //if (response.Headers == null) //{ // response.Headers = new Dictionary(); //} //response.Headers["Cache-Control"] = return response; } } public enum Cachable { @Public, @Private, NoCache, NoStore, } public enum CacheRevalidation { MustRevalidate, ProxyRevalidate, } }