1
0
Fork 0
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:
Julien Voisin 2025-08-06 04:35:27 +02:00 committed by GitHub
parent b1cbaae71c
commit 798bc4cd2d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 33 additions and 29 deletions

View file

@ -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()
})
}