Skip to content
This repository has been archived by the owner on Jul 30, 2020. It is now read-only.

Commit

Permalink
rgetserver: add helpful root template
Browse files Browse the repository at this point in the history
  • Loading branch information
philips committed Aug 5, 2019
1 parent 0fe0344 commit 14a5098
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions rgetserver/rgetserver.go
Expand Up @@ -28,6 +28,7 @@ type release struct {

var (
releaseTemplate *template.Template
rootTemplate *template.Template
)

func init() {
Expand All @@ -40,6 +41,19 @@ func init() {
</ul>
</body>
</html>`))

rootTemplate = template.Must(template.New("root").Parse(`<html>
<head><title>Merkle County</title></head>
<body>
<h2>Merkle County</h2>
<ul>
<li><a href="https://merklecounty.substack.com">Newsletter and Blog</a></li>
<li><a href="https://github.com/merklecounty/rget">GitHub</a></li>
<li><a href="https://go.merklecounty.com">Go Packages</a></li>
</ul>
</body>
</html>`))

}

func (s Server) ReleaseHandler(resp http.ResponseWriter, req *http.Request) {
Expand All @@ -48,6 +62,11 @@ func (s Server) ReleaseHandler(resp http.ResponseWriter, req *http.Request) {
return
}

if req.Host == rgetwellknown.PublicServiceHost {
rootTemplate.Execute(resp, nil)
return
}

short, err := rgetwellknown.TrimDigestDomain(req.Host)
if err != nil {
fmt.Printf("request for unknown host %v unable to parse: %v\n", req.Host, err)
Expand Down

0 comments on commit 14a5098

Please sign in to comment.