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`**
This commit is contained in:
12
api.go
12
api.go
@@ -7,12 +7,18 @@ import (
|
||||
|
||||
"github.com/franela/play-with-docker/handlers"
|
||||
"github.com/franela/play-with-docker/services"
|
||||
"github.com/franela/play-with-docker/templates"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/urfave/negroni"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
welcome, tmplErr := templates.GetWelcomeTemplate()
|
||||
if tmplErr != nil {
|
||||
log.Fatal(tmplErr)
|
||||
}
|
||||
|
||||
server := services.CreateWSServer()
|
||||
|
||||
server.On("connection", handlers.WS)
|
||||
@@ -27,7 +33,11 @@ func main() {
|
||||
r.StrictSlash(false)
|
||||
|
||||
r.HandleFunc("/ping", http.HandlerFunc(handlers.Ping)).Methods("GET")
|
||||
r.HandleFunc("/", http.HandlerFunc(handlers.NewSession)).Methods("GET")
|
||||
r.HandleFunc("/", http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
|
||||
rw.Write(welcome)
|
||||
})).Methods("GET")
|
||||
r.HandleFunc("/", http.HandlerFunc(handlers.NewSession)).Methods("POST")
|
||||
|
||||
r.HandleFunc("/sessions/{sessionId}", http.HandlerFunc(handlers.GetSession)).Methods("GET")
|
||||
r.HandleFunc("/sessions/{sessionId}/instances", http.HandlerFunc(handlers.NewInstance)).Methods("POST")
|
||||
r.HandleFunc("/sessions/{sessionId}/instances/{instanceName}", http.HandlerFunc(handlers.DeleteInstance)).Methods("DELETE")
|
||||
|
||||
Reference in New Issue
Block a user