This commit is contained in:
James Mills 2017-06-26 01:48:07 -07:00
parent 11fb233d11
commit da3c29209f
No known key found for this signature in database
GPG Key ID: AC4C014F1440EBD6
2 changed files with 15 additions and 4 deletions

View File

@ -3,7 +3,7 @@ FROM golang:alpine
EXPOSE 80/tcp
ENTRYPOINT ["gopherproxy"]
CMD []
CMD ["-bind", "0.0.0.0:80", "-uri", "floodgap.com"]
RUN \
apk add --update git && \

View File

@ -23,9 +23,16 @@ type tplRow struct {
type Handler func(w http.ResponseWriter, req *http.Request)
func renderDirectory(w http.ResponseWriter, tpl *template.Template, hostport string, d gopher.Directory) error {
out := make([]tplRow, len(d))
var title string
out := make([]tplRow, len(d.Items))
for i, x := range d.Items {
if x.Type == gopher.INFO && x.Selector == "TITLE" {
title = x.Description
continue
}
for i, x := range d {
tr := tplRow{
Text: x.Description,
Type: x.Type.String(),
@ -60,10 +67,14 @@ func renderDirectory(w http.ResponseWriter, tpl *template.Template, hostport str
out[i] = tr
}
if title == "" {
title = hostport
}
return tpl.Execute(w, struct {
Title string
Lines []tplRow
}{hostport, out})
}{title, out})
}
// MakeGopherProxyHandler returns a Handler that proxies requests