From a5f77f7913e3d20e4f365f71966c128fa52d129a Mon Sep 17 00:00:00 2001 From: Fabricio Date: Fri, 7 Sep 2018 13:41:24 -0300 Subject: [PATCH] convert url to string --- README.md | 1 - args.go | 16 ++++++---------- main.go | 3 ++- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 728478a..56a8a2e 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,6 @@ For ready-to-use executables for *Windows*, *Linux* and *Mac*, see [Releases](ht | `-port` | Set the proxy port. Default: *9000* | | `-dashboard` | Set the dashboard's name. Default: *dashboard* | | `-max-captures` | Set the max number of captures to show in the dashboard. Default: *16* | -| `-h` | Show help | ## Using diff --git a/args.go b/args.go index 9d2882f..942d38f 100644 --- a/args.go +++ b/args.go @@ -1,15 +1,12 @@ package main -import ( - "flag" - "net/url" -) +import "flag" type Args struct { - TargetURL *url.URL `json:"targetURL"` - ProxyPort string `json:"proxyPort"` - Dashboard string `json:"dashboard"` - MaxCaptures int `json:"maxCaptures"` + TargetURL string `json:"targetURL"` + ProxyPort string `json:"proxyPort"` + Dashboard string `json:"dashboard"` + MaxCaptures int `json:"maxCaptures"` } func ParseArgs() Args { @@ -18,6 +15,5 @@ func ParseArgs() Args { dashboard := flag.String("dashboard", "dashboard", "Set the dashboard name") maxCaptures := flag.Int("max-captures", 16, "Set the max number of captures to show in the dashboard") flag.Parse() - url, _ := url.Parse(*targetURL) - return Args{url, *proxyPort, *dashboard, *maxCaptures} + return Args{*targetURL, *proxyPort, *dashboard, *maxCaptures} } diff --git a/main.go b/main.go index 219f2a5..9ffb849 100644 --- a/main.go +++ b/main.go @@ -95,7 +95,8 @@ func getDashboardItemInfoHandler() http.Handler { }) } -func getProxyHandler(url *url.URL, transp *transport) http.Handler { +func getProxyHandler(targetURL string, transp *transport) http.Handler { + url, _ := url.Parse(targetURL) proxy := httputil.NewSingleHostReverseProxy(url) proxy.Transport = transp return http.HandlerFunc(func(response http.ResponseWriter, request *http.Request) {