diff options
-rw-r--r-- | main.go | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -16,6 +16,7 @@ import ( | |||
16 | 16 | ||
17 | var ( | 17 | var ( |
18 | bind = flag.String("bind", ":80", "[int]:port to bind to") | 18 | bind = flag.String("bind", ":80", "[int]:port to bind to") |
19 | uri = flag.String("uri", "127.0.0.1:70", "<host>:[port] to proxy to") | ||
19 | 20 | ||
20 | tpl *template.Template | 21 | tpl *template.Template |
21 | ) | 22 | ) |
@@ -67,6 +68,11 @@ func proxy(w http.ResponseWriter, req *http.Request) { | |||
67 | hostport := parts[0] | 68 | hostport := parts[0] |
68 | path := strings.Join(parts[1:], "/") | 69 | path := strings.Join(parts[1:], "/") |
69 | 70 | ||
71 | if len(hostport) == 0 { | ||
72 | http.Redirect(w, req, "/"+*uri, http.StatusFound) | ||
73 | return | ||
74 | } | ||
75 | |||
70 | res, err := gopher.Get( | 76 | res, err := gopher.Get( |
71 | fmt.Sprintf( | 77 | fmt.Sprintf( |
72 | "gopher://%s/%s", | 78 | "gopher://%s/%s", |