Added API usage instructions

This commit is contained in:
2018-11-24 04:18:26 +00:00
committed by cdramey
parent b3ee5c5e1b
commit 0216358dfb
3 changed files with 61 additions and 2 deletions

View File

@ -15,6 +15,7 @@ type RootHandler struct {
index *static.StaticContent
css *static.StaticContent
favi *static.StaticContent
usage *static.StaticContent
submit *template.Template
}
@ -36,6 +37,9 @@ func (ctx *RootHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
case "/favicon.ico":
ctx.favi.ServeHTTP(w, r)
case "/api/usage.html":
ctx.usage.ServeHTTP(w, r)
case "/api/url":
ctx.ServeAPI(w, r)
@ -73,7 +77,7 @@ func (ctx *RootHandler) Init() error {
}
ctx.css = css
// Initialize the static content object for the css
// Initialize the static content object favicon
favi := &static.StaticContent{Content: "favicon.ico"}
err = favi.Init()
if err != nil {
@ -81,6 +85,14 @@ func (ctx *RootHandler) Init() error {
}
ctx.favi = favi
// Initialize the api usage instructions
usage := &static.StaticContent{Content: "usage.html"}
err = usage.Init()
if err != nil {
return err
}
ctx.usage = usage
// Initialize submit page template
ctx.submit = template.New("submit.html")
_, err = ctx.submit.Parse(string(static.Assets["submit.html"]))