Compare commits
2 Commits
56f98a9c14
...
a2d09d8e68
| Author | SHA1 | Date | |
|---|---|---|---|
| a2d09d8e68 | |||
| a52e76c0da |
2
main.go
2
main.go
@ -38,7 +38,7 @@ func ConnectDB() *sql.DB {
|
||||
func main() {
|
||||
csrfKey := []byte(os.Getenv("LENSLOCKED_CSRF_KEY"))
|
||||
if len(csrfKey) < 32 {
|
||||
panic("Error: bad csrf protection key")
|
||||
panic("Error: bad csrf protection key\nPlease set a key with the LENSLOCKED_CSRF_KEY env var.")
|
||||
}
|
||||
|
||||
db := ConnectDB()
|
||||
|
||||
@ -42,6 +42,11 @@ func (t Template) TestTemplate(data interface{}) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tpl = tpl.Funcs(template.FuncMap{
|
||||
"csrfField": func() template.HTML {
|
||||
return `<div class="hidden">STUB: PLACEHOLDER</div>`
|
||||
},
|
||||
})
|
||||
return tpl.Execute(&testWriter, data)
|
||||
}
|
||||
|
||||
@ -52,8 +57,8 @@ func FromFile(pattern ...string) (Template, error) {
|
||||
func FromFS(fs fs.FS, pattern ...string) (Template, error) {
|
||||
tpl := template.New(pattern[0])
|
||||
tpl = tpl.Funcs(template.FuncMap{
|
||||
"csrfField": func() template.HTML {
|
||||
return `<div class="hidden">STUB: PLACEHOLDER</div>`
|
||||
"csrfField": func() (template.HTML, error) {
|
||||
return `<div class="hidden">STUB: PLACEHOLDER</div>`, fmt.Errorf("csrfField Not Implimented")
|
||||
},
|
||||
})
|
||||
tpl, err := tpl.ParseFS(fs, pattern...)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user