summaryrefslogtreecommitdiff
path: root/page/page.go
diff options
context:
space:
mode:
Diffstat (limited to 'page/page.go')
-rw-r--r--page/page.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/page/page.go b/page/page.go
index c58a344..8b44f06 100644
--- a/page/page.go
+++ b/page/page.go
@@ -40,7 +40,7 @@ func (p Pages) ServeError500(w http.ResponseWriter) {
}
-type DefaultPage func() (string, error)
+type DefaultPage func(api config.Api) (string, error)
func fileExists(filename string) (bool, error) {
@@ -56,7 +56,7 @@ func fileExists(filename string) (bool, error) {
}
-func loadPage(c config.Config, filename string, fallback DefaultPage) (string, error) {
+func loadPage(c config.Config, api config.Api, filename string, fallback DefaultPage) (string, error) {
fullPath := filepath.Join(c.AssetDirectory, filename)
exist, err := fileExists(fullPath)
if err != nil {
@@ -72,7 +72,7 @@ func loadPage(c config.Config, filename string, fallback DefaultPage) (string, e
} else {
// file does not exist
// use built-in
- str, err := fallback()
+ str, err := fallback(api)
if err != nil {
return "", err
}
@@ -81,27 +81,27 @@ func loadPage(c config.Config, filename string, fallback DefaultPage) (string, e
}
-func LoadPages(c config.Config) (Pages, error) {
+func LoadPages(c config.Config, api config.Api) (Pages, error) {
var pages Pages
var err error
- pages.Login, err = loadPage(c, "login.html", DefaultLogin)
+ pages.Login, err = loadPage(c, api, "login.html", DefaultLogin)
if err != nil {
return Pages{}, err
}
- pages.LoggedIn, err = loadPage(c, "logged_in.html", DefaultLoggedIn)
+ pages.LoggedIn, err = loadPage(c, api, "logged_in.html", DefaultLoggedIn)
if err != nil {
return Pages{}, err
}
- pages.Error404, err = loadPage(c, "404.html", DefaultError404)
+ pages.Error404, err = loadPage(c, api, "404.html", DefaultError404)
if err != nil {
return Pages{}, err
}
- pages.Error500, err = loadPage(c, "500.html", DefaultError500)
+ pages.Error500, err = loadPage(c, api, "500.html", DefaultError500)
if err != nil {
return Pages{}, err
}