1
0
mirror of https://github.com/bingohuang/docker-labs.git synced 2025-07-15 02:37:27 +08:00
docker-labs/templates/welcome.go
Jonathan Leibiusky @xetorthio af9986c0f8 Validates that user is a human.
Add google recaptcha as an initial page before creating any session.
To configure recaptcha there are 2 environment variables that are needed
`GOOGLE_RECAPTCHA_SITE_KEY` and `GOOGLE_RECAPTCHA_SITE_SECRET`.
The code contains development defaults that should be set in production
to real values.
**NOTICE: Development defaults assume that the domain is `localhost`**
2016-11-15 16:53:44 -03:00

22 lines
501 B
Go

package templates
import (
"bytes"
"html/template"
"github.com/franela/play-with-docker/services"
)
func GetWelcomeTemplate() ([]byte, error) {
welcomeTemplate, tplErr := template.New("welcome").ParseFiles("www/welcome.html")
if tplErr != nil {
return nil, tplErr
}
var b bytes.Buffer
tplExecuteErr := welcomeTemplate.ExecuteTemplate(&b, "GOOGLE_RECAPTCHA_SITE_KEY", services.GetGoogleRecaptchaSiteKey())
if tplExecuteErr != nil {
return nil, tplExecuteErr
}
return b.Bytes(), nil
}