mirror of
https://github.com/miniflux/v2.git
synced 2025-08-11 17:51:01 +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
|
@ -21,14 +21,14 @@ const licenseSuffix = "\n//@license-end"
|
|||
|
||||
func (h *handler) showJavascript(w http.ResponseWriter, r *http.Request) {
|
||||
filename := request.RouteStringParam(r, "name")
|
||||
etag, found := static.JavascriptBundleChecksums[filename]
|
||||
js, found := static.JavascriptBundles[filename]
|
||||
if !found {
|
||||
html.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
response.New(w, r).WithCaching(etag, 48*time.Hour, func(b *response.Builder) {
|
||||
contents := static.JavascriptBundles[filename]
|
||||
response.New(w, r).WithCaching(js.Checksum, 48*time.Hour, func(b *response.Builder) {
|
||||
contents := js.Data
|
||||
|
||||
if filename == "service-worker" {
|
||||
variables := fmt.Sprintf(`const OFFLINE_URL=%q;`, route.Path(h.router, "offline"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue