package page
import (
"strings"
"text/template"
)
type page struct {
Title string
Body string
}
func buildPage(p page) (string, error) {
t, err := template.New("").Parse(`
{{ .Title }}
{{ .Body }}
`)
if err != nil {
return "", err
}
var b strings.Builder
err = t.Execute(&b, p)
if err != nil {
return "", err
}
return b.String(), nil
}
func DefaultLogin() (string, error) {
return buildPage(page{
Title: "Login",
Body: `
`,
})
}
func DefaultLoggedIn() (string, error) {
return buildPage(page{
Title: "Logged In",
Body: `
You are logged in.
`,
})
}
func DefaultError404() (string, error) {
return buildPage(page{
Title: "404 Not Found",
Body: "Error 404: Page not found
",
})
}
func DefaultError500() (string, error) {
return buildPage(page{
Title: "500 Not Found",
Body: "Error 500: Page not found
",
})
}