mirror of
https://github.com/miniflux/v2.git
synced 2025-09-15 18:57:04 +00:00
refactor(static): use a simple struct instead of two slices to store assets data and checksums
- Use a simple struct instead of two slices to store the data and the checksums of resources - Remove a superfluous call to Sprintf - Factorise presence check and data retrieval in some maps - Size the maps when possible
This commit is contained in:
parent
b1cbaae71c
commit
798bc4cd2d
4 changed files with 33 additions and 29 deletions
|
@ -15,15 +15,15 @@ import (
|
|||
|
||||
func (h *handler) showStylesheet(w http.ResponseWriter, r *http.Request) {
|
||||
filename := request.RouteStringParam(r, "name")
|
||||
etag, found := static.StylesheetBundleChecksums[filename]
|
||||
m, found := static.StylesheetBundles[filename]
|
||||
if !found {
|
||||
html.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
response.New(w, r).WithCaching(etag, 48*time.Hour, func(b *response.Builder) {
|
||||
response.New(w, r).WithCaching(m.Checksum, 48*time.Hour, func(b *response.Builder) {
|
||||
b.WithHeader("Content-Type", "text/css; charset=utf-8")
|
||||
b.WithBody(static.StylesheetBundles[filename])
|
||||
b.WithBody(m.Data)
|
||||
b.Write()
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue