debian-mirror-gitlab/workhorse/internal/staticpages/deploy_page.go
2023-03-04 22:38:38 +05:30

24 lines
510 B
Go

package staticpages
import (
"net/http"
"os"
"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) {
data, err := os.ReadFile(deployPage)
if err != nil {
handler.ServeHTTP(w, r)
return
}
setNoCacheHeaders(w.Header())
w.Header().Set("Content-Type", "text/html; charset=utf-8")
w.WriteHeader(http.StatusOK)
w.Write(data)
})
}