debian-mirror-gitlab/workhorse/internal/staticpages/deploy_page.go

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

25 lines
510 B
Go
Raw Normal View History

2021-02-22 17:27:13 +05:30
package staticpages
import (
"net/http"
2022-07-23 23:45:48 +05:30
"os"
2021-02-22 17:27:13 +05:30
"path/filepath"
)
func (s *Static) DeployPage(handler http.Handler) http.Handler {
deployPage := filepath.Join(s.DocumentRoot, "index.html")
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
2022-07-23 23:45:48 +05:30
data, err := os.ReadFile(deployPage)
2021-02-22 17:27:13 +05:30
if err != nil {
handler.ServeHTTP(w, r)
return
}
2023-03-04 22:38:38 +05:30
setNoCacheHeaders(w.Header())
2021-02-22 17:27:13 +05:30
w.Header().Set("Content-Type", "text/html; charset=utf-8")
w.WriteHeader(http.StatusOK)
w.Write(data)
})
}