Add CLI flag to run-server.go for local plugins

Allows to map URL requests to local folder structure.
For example, to run against local gerrit-testsite:

/polygerrit-ui/run-server.sh \
  --host=localhost:8080 \
  --scheme=http \
  --plugins=$HOME/gerrit-testsite/plugins/

Change-Id: I20510eb1c2cff93d253aa9f7f38bc42f59f557e9
This commit is contained in:
Viktar Donich 2017-02-08 11:31:31 -08:00
parent 23929fc5ff
commit 70222ad0b6
1 changed files with 6 additions and 0 deletions

View File

@ -33,6 +33,7 @@ var (
port = flag.String("port", ":8081", "Port to serve HTTP requests on")
prod = flag.Bool("prod", false, "Serve production assets")
scheme = flag.String("scheme", "https", "URL scheme")
plugins = flag.String("plugins", "", "Path to local plugins folder")
)
func main() {
@ -49,6 +50,11 @@ func main() {
http.HandleFunc("/config/", handleRESTProxy)
http.HandleFunc("/projects/", handleRESTProxy)
http.HandleFunc("/accounts/self/detail", handleAccountDetail)
if len(*plugins) > 0 {
http.Handle("/plugins/", http.StripPrefix("/plugins/",
http.FileServer(http.Dir(*plugins))))
log.Println("Local plugins at", *plugins)
}
log.Println("Serving on port", *port)
log.Fatal(http.ListenAndServe(*port, &server{}))
}