From 965c449f1c578340405df020cbdaa0f10bdfec67 Mon Sep 17 00:00:00 2001 From: Harvey Tindall Date: Thu, 14 Jan 2021 14:18:12 +0000 Subject: [PATCH] attempt to use http2 server push --- views.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/views.go b/views.go index d3939a8..01af549 100644 --- a/views.go +++ b/views.go @@ -22,6 +22,14 @@ func (app *appContext) AdminPage(gc *gin.Context) { emailEnabled, _ := app.config.Section("invite_emails").Key("enabled").Bool() notificationsEnabled, _ := app.config.Section("notifications").Key("enabled").Bool() ombiEnabled := app.config.Section("ombi").Key("enabled").MustBool(false) + if pusher := gc.Writer.Pusher(); pusher != nil { + toPush := []string{"/js/admin.js", "/js/theme.js", "/js/lang.js", "/js/modal.js", "/js/tabs.js", "/js/invites.js", "/js/accounts.js", "/js/settings.js", "/js/profiles.js", "/js/common.js"} + for _, f := range toPush { + if err := pusher.Push(f, nil); err != nil { + app.debug.Printf("Failed HTTP2 ServerPush of \"%s\": %+v", f, err) + } + } + } gcHTML(gc, http.StatusOK, "admin.html", gin.H{ "urlBase": app.URLBase, "cssClass": app.cssClass,