grpc-zpages: clarify statics assets start up message (#308)
The message right now is confusing, and may lead to users navigating here instead of the envoy port. Ran gofmt move flags to pkg level, avoid http mux
This commit is contained in:
parent
851a674d9b
commit
2d5ed88f1c
|
|
@ -1,29 +1,30 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
var port = flag.Int("port", 8080, "local port")
|
||||||
var port = flag.Int("port", 8080, "local port")
|
var wwwRoot = flag.String("wwwroot", "/www", "root for http files")
|
||||||
var wwwRoot = flag.String("wwwroot", "/www", "root for http files")
|
|
||||||
flag.Parse()
|
|
||||||
|
|
||||||
mux := http.NewServeMux()
|
func main() {
|
||||||
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
flag.Parse()
|
||||||
fmt.Printf("Got request %s\n", r.URL.Path)
|
|
||||||
localPath := path.Join(*wwwRoot, r.URL.Path[1:])
|
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
if (strings.HasSuffix(localPath, ".css") || strings.HasSuffix(localPath, ".js")) {
|
fmt.Printf("Got request %s\n", r.URL.Path)
|
||||||
http.ServeFile(w, r, localPath)
|
localPath := path.Join(*wwwRoot, r.URL.Path[1:])
|
||||||
} else {
|
if strings.HasSuffix(localPath, ".css") || strings.HasSuffix(localPath, ".js") {
|
||||||
http.ServeFile(w, r, path.Join(*wwwRoot, "dist_channelz/index.html"))
|
http.ServeFile(w, r, localPath)
|
||||||
}
|
} else {
|
||||||
})
|
http.ServeFile(w, r, path.Join(*wwwRoot, "dist_channelz/index.html"))
|
||||||
fmt.Printf("Starting server on port %d...\n", *port)
|
}
|
||||||
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *port), mux))
|
})
|
||||||
|
fmt.Printf("Starting static assets server on port %d . Note this is not the envoy port!\n"+
|
||||||
|
"You should not need to look at this port unless you know what you're doing.\n", *port)
|
||||||
|
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *port), nil))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue