Use `url.URL` for constructing URLs
This commit is contained in:
parent
ca14394ec8
commit
4df9ac8059
14
app/app.go
14
app/app.go
|
@ -10,6 +10,7 @@ import (
|
||||||
"math/big"
|
"math/big"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -120,10 +121,19 @@ func (app *App) Run() error {
|
||||||
strings.Join(app.options.Command, " "),
|
strings.Join(app.options.Command, " "),
|
||||||
)
|
)
|
||||||
if app.options.Address != "" {
|
if app.options.Address != "" {
|
||||||
log.Printf("URL: %s", "http://"+endpoint+path+"/")
|
log.Printf(
|
||||||
|
"URL: %s", (&url.URL{Scheme: "http", Host: endpoint, Path: path + "/"}).String(),
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
for _, address := range listAddresses() {
|
for _, address := range listAddresses() {
|
||||||
log.Printf("URL: %s", "http://"+net.JoinHostPort(address, app.options.Port)+path+"/")
|
log.Printf(
|
||||||
|
"URL: %s",
|
||||||
|
(&url.URL{
|
||||||
|
Scheme: "http",
|
||||||
|
Host: net.JoinHostPort(address, app.options.Port),
|
||||||
|
Path: path + "/",
|
||||||
|
}).String(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := http.ListenAndServe(endpoint, siteHandler); err != nil {
|
if err := http.ListenAndServe(endpoint, siteHandler); err != nil {
|
||||||
|
|
Loading…
Reference in New Issue