From fb383bcaec715e3f53f5bad6aa9a2881bb698fb3 Mon Sep 17 00:00:00 2001 From: James Mills Date: Fri, 23 Sep 2016 21:36:31 +1000 Subject: Add -url CLI flag for default proxy target and redirect for / --- main.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/main.go b/main.go index 766ece3..4ab9579 100644 --- a/main.go +++ b/main.go @@ -16,6 +16,7 @@ import ( var ( bind = flag.String("bind", ":80", "[int]:port to bind to") + uri = flag.String("uri", "127.0.0.1:70", ":[port] to proxy to") tpl *template.Template ) @@ -67,6 +68,11 @@ func proxy(w http.ResponseWriter, req *http.Request) { hostport := parts[0] path := strings.Join(parts[1:], "/") + if len(hostport) == 0 { + http.Redirect(w, req, "/"+*uri, http.StatusFound) + return + } + res, err := gopher.Get( fmt.Sprintf( "gopher://%s/%s", -- cgit v1.2.3-54-g00ecf