Replace www-path with www-proxy option for development (#248)

By adding a new ENV variable called `WOODPECKER_WWW_PROXY` it is possible to serve a webinterface via a proxy configured by the `WOODPECKER_WWW_PROXY` value for development instead of serving the interface from the bundled code or from some folder location as the old `WOODPECKER_WWW` option allowed. Using a proxy allows developing the UI with hot-reloading.
This commit is contained in:
Anbraten
2021-09-27 00:22:23 +02:00
committed by GitHub
parent da6fa0ec70
commit bd19f90756
7 changed files with 27 additions and 47 deletions

View File

@@ -19,9 +19,7 @@ import (
"crypto/md5"
"fmt"
"html/template"
"io/ioutil"
"net/http"
"path/filepath"
"time"
"github.com/woodpecker-ci/woodpecker/model"
@@ -45,10 +43,6 @@ func New(opt ...Option) Endpoint {
f(opts)
}
if opts.path != "" {
return fromPath(opts)
}
return &website{
fs: dist.New(),
opts: opts,
@@ -58,19 +52,6 @@ func New(opt ...Option) Endpoint {
}
}
func fromPath(opts *Options) *website {
f := filepath.Join(opts.path, "index.html")
b, err := ioutil.ReadFile(f)
if err != nil {
panic(err)
}
return &website{
fs: http.Dir(opts.path),
tmpl: mustCreateTemplate(string(b)),
opts: opts,
}
}
type website struct {
opts *Options
fs http.FileSystem