Commit 4df9ac80 by Iwasaki Yudai

Use `url.URL` for constructing URLs

1 parent ca14394e
Showing with 12 additions and 2 deletions
......@@ -10,6 +10,7 @@ import (
"math/big"
"net"
"net/http"
"net/url"
"os"
"os/exec"
"strconv"
......@@ -120,10 +121,19 @@ func (app *App) Run() error {
strings.Join(app.options.Command, " "),
)
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 {
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 {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!