mirror of
https://github.com/prymitive/karma
synced 2026-05-07 03:26:52 +00:00
feat(backend): enable HTTP/2 push for custom.(js|css)
This commit is contained in:
committed by
Łukasz Mierzwa
parent
bed69c10e1
commit
4bc4e7f539
@@ -79,8 +79,18 @@ func decompressCachedResponse(data []byte) ([]byte, error) {
|
||||
return p, nil
|
||||
}
|
||||
|
||||
func pushPath(w http.ResponseWriter, path string) {
|
||||
if pusher, ok := w.(http.Pusher); ok {
|
||||
if err := pusher.Push(path, nil); err != nil {
|
||||
log.Warn().Str("path", path).Msg("Failed to push server path via HTTP/2")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func index(w http.ResponseWriter, r *http.Request) {
|
||||
noCache(w)
|
||||
pushPath(w, getViewURL("/custom.css"))
|
||||
pushPath(w, getViewURL("/custom.js"))
|
||||
|
||||
filtersJSON, _ := json.Marshal(config.Config.Filters.Default)
|
||||
filtersB64 := base64.StdEncoding.EncodeToString(filtersJSON)
|
||||
|
||||
Reference in New Issue
Block a user