updated to make better use of go 1.16 features

This commit is contained in:
2021-06-27 09:29:31 -08:00
parent d272cafd2e
commit 2510448ed7
33 changed files with 47 additions and 4888 deletions

View File

@ -3,8 +3,8 @@ package pages
import (
"fmt"
"git.binarythought.com/cdramey/qurl/obj"
"git.binarythought.com/cdramey/qurl/static"
"git.binarythought.com/cdramey/qurl/storage"
"git.binarythought.com/cdramey/qurl/assets"
"html/template"
"net/http"
)
@ -68,24 +68,44 @@ func (ctx *RootHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
func (ctx *RootHandler) Init() error {
// Initialize the static content object for the index page
ctx.index = &StaticContent{Type: "text/html", Content: static.Index_html}
data, err := assets.ReadFile("index.html")
if err != nil {
return err
}
ctx.index = &StaticContent{Type: "text/html", Content: data }
ctx.index.Init()
// Initialize the static content object for the css
ctx.css = &StaticContent{Type: "text/css", Content: static.Qurl_css}
data, err = assets.ReadFile("qurl.css")
if err != nil {
return err
}
ctx.css = &StaticContent{Type: "text/css", Content: data }
ctx.css.Init()
// Initialize the static content object favicon
ctx.favi = &StaticContent{Type: "image/x-icon", Content: static.Favicon_ico}
data, err = assets.ReadFile("favicon.ico")
if err != nil {
return err
}
ctx.favi = &StaticContent{Type: "image/x-icon", Content: data}
ctx.favi.Init()
// Initialize the api usage instructions
ctx.usage = &StaticContent{Type: "text/html", Content: static.Usage_html}
data, err = assets.ReadFile("usage.html")
if err != nil {
return err
}
ctx.usage = &StaticContent{Type: "text/html", Content: data}
ctx.usage.Init()
// Initialize submit page template
data, err = assets.ReadFile("submit.html")
if err != nil {
return err
}
ctx.submit = template.New("submit.html")
_, err := ctx.submit.Parse(string(static.Submit_html))
_, err = ctx.submit.Parse(string(data))
if err != nil {
return err
}