aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Mills <prologic@shortcircuit.net.au>2017-06-26 01:48:07 -0700
committerJames Mills <prologic@shortcircuit.net.au>2017-06-26 01:48:07 -0700
commitda3c29209fb9519913f5eb4fcc1b1a4986464f03 (patch)
treefa1f0c14a9bf6a421d6e57cea6540a72b4308854
parentAdd gorelease config to travis for automated binary releases (diff)
downloadgopherproxy-da3c29209fb9519913f5eb4fcc1b1a4986464f03.tar.gz
gopherproxy-da3c29209fb9519913f5eb4fcc1b1a4986464f03.tar.bz2
gopherproxy-da3c29209fb9519913f5eb4fcc1b1a4986464f03.zip
Bump
-rw-r--r--Dockerfile2
-rw-r--r--gopherproxy.go17
2 files changed, 15 insertions, 4 deletions
diff --git a/Dockerfile b/Dockerfile
index bf5cab6..ddba3aa 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -3,7 +3,7 @@ FROM golang:alpine
3EXPOSE 80/tcp 3EXPOSE 80/tcp
4 4
5ENTRYPOINT ["gopherproxy"] 5ENTRYPOINT ["gopherproxy"]
6CMD [] 6CMD ["-bind", "0.0.0.0:80", "-uri", "floodgap.com"]
7 7
8RUN \ 8RUN \
9 apk add --update git && \ 9 apk add --update git && \
diff --git a/gopherproxy.go b/gopherproxy.go
index 8c85448..fcce1ee 100644
--- a/gopherproxy.go
+++ b/gopherproxy.go
@@ -23,9 +23,16 @@ type tplRow struct {
23type Handler func(w http.ResponseWriter, req *http.Request) 23type Handler func(w http.ResponseWriter, req *http.Request)
24 24
25func renderDirectory(w http.ResponseWriter, tpl *template.Template, hostport string, d gopher.Directory) error { 25func renderDirectory(w http.ResponseWriter, tpl *template.Template, hostport string, d gopher.Directory) error {
26 out := make([]tplRow, len(d)) 26 var title string
27
28 out := make([]tplRow, len(d.Items))
29
30 for i, x := range d.Items {
31 if x.Type == gopher.INFO && x.Selector == "TITLE" {
32 title = x.Description
33 continue
34 }
27 35
28 for i, x := range d {
29 tr := tplRow{ 36 tr := tplRow{
30 Text: x.Description, 37 Text: x.Description,
31 Type: x.Type.String(), 38 Type: x.Type.String(),
@@ -60,10 +67,14 @@ func renderDirectory(w http.ResponseWriter, tpl *template.Template, hostport str
60 out[i] = tr 67 out[i] = tr
61 } 68 }
62 69
70 if title == "" {
71 title = hostport
72 }
73
63 return tpl.Execute(w, struct { 74 return tpl.Execute(w, struct {
64 Title string 75 Title string
65 Lines []tplRow 76 Lines []tplRow
66 }{hostport, out}) 77 }{title, out})
67} 78}
68 79
69// MakeGopherProxyHandler returns a Handler that proxies requests 80// MakeGopherProxyHandler returns a Handler that proxies requests