embed index.html
This commit is contained in:
parent
d5664a729e
commit
21c84c9f6e
2 changed files with 19 additions and 1 deletions
|
@ -7,8 +7,13 @@ import (
|
|||
"strings"
|
||||
|
||||
"gitea.nulo.in/Nulo/repro-run/gitea-ci/gitea"
|
||||
|
||||
_ "embed"
|
||||
)
|
||||
|
||||
//go:embed index.html
|
||||
var index []byte
|
||||
|
||||
func main() {
|
||||
config := parseConfig()
|
||||
|
||||
|
@ -31,7 +36,7 @@ func main() {
|
|||
|
||||
http.Handle("/webhook", webhook{config: config, gitea: g})
|
||||
http.Handle("/logs/socket/", logWebsocket{})
|
||||
http.Handle("/", http.FileServer(http.Dir(".")))
|
||||
http.Handle("/", staticRoute{file: index, mime: "text/html; charset=utf-8"})
|
||||
log.Fatal(http.ListenAndServe(port, nil))
|
||||
}
|
||||
|
||||
|
|
13
gitea-ci/static.go
Normal file
13
gitea-ci/static.go
Normal file
|
@ -0,0 +1,13 @@
|
|||
package main
|
||||
|
||||
import "net/http"
|
||||
|
||||
type staticRoute struct {
|
||||
file []byte
|
||||
mime string
|
||||
}
|
||||
|
||||
func (s staticRoute) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||
w.Header().Add("Content-Type", s.mime)
|
||||
w.Write(s.file)
|
||||
}
|
Loading…
Reference in a new issue