diff options
author | 2018-10-07 18:42:43 -0700 | |
---|---|---|
committer | 2018-10-08 15:31:58 -0700 | |
commit | 1f58b37a5e86603b16e137031c36f37580e9d410 (patch) | |
tree | 337a7299e91fe7640b64489357dfe7c0f00e2313 /ui/static_stylesheet.go | |
parent | ddfe969d6cbc8d23326cb9a3ca9a265d4e9d3e45 (diff) | |
download | v2-1f58b37a5e86603b16e137031c36f37580e9d410.tar.gz v2-1f58b37a5e86603b16e137031c36f37580e9d410.tar.zst v2-1f58b37a5e86603b16e137031c36f37580e9d410.zip |
Refactor HTTP response builder
Diffstat (limited to 'ui/static_stylesheet.go')
-rw-r--r-- | ui/static_stylesheet.go | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/ui/static_stylesheet.go b/ui/static_stylesheet.go index 8e475bdc..9a21bc61 100644 --- a/ui/static_stylesheet.go +++ b/ui/static_stylesheet.go @@ -16,14 +16,16 @@ import ( // Stylesheet renders the CSS. func (c *Controller) Stylesheet(w http.ResponseWriter, r *http.Request) { - stylesheet := request.RouteStringParam(r, "name") - if _, found := static.Stylesheets[stylesheet]; !found { - html.NotFound(w) + filename := request.RouteStringParam(r, "name") + etag, found := static.StylesheetsChecksums[filename] + if !found { + html.NotFound(w, r) return } - body := static.Stylesheets[stylesheet] - etag := static.StylesheetsChecksums[stylesheet] - - response.Cache(w, r, "text/css; charset=utf-8", etag, []byte(body), 48*time.Hour) + response.New(w, r).WithCaching(etag, 48*time.Hour, func(b *response.Builder) { + b.WithHeader("Content-Type", "text/css; charset=utf-8") + b.WithBody(static.Stylesheets[filename]) + b.Write() + }) } |