Expiration time now being get from CaptchaDB.

This commit is contained in:
Alexander Andreev 2022-06-26 15:45:42 +04:00
parent c5d159531c
commit 4af8d67299
Signed by: Arav
GPG Key ID: 0388CC8FAA51063F

View File

@ -6,20 +6,16 @@ import (
"justcaptcha/internal/captcha" "justcaptcha/internal/captcha"
"justcaptcha/pkg/server" "justcaptcha/pkg/server"
"net/http" "net/http"
"time"
) )
type CaptchaHandlers struct { type CaptchaHandlers struct{}
ExpireIn time.Duration
}
func New(expiration time.Duration) *CaptchaHandlers { func New() *CaptchaHandlers {
return &CaptchaHandlers{ return &CaptchaHandlers{}
ExpireIn: expiration}
} }
func (h *CaptchaHandlers) New(w http.ResponseWriter, r *http.Request) { func (h *CaptchaHandlers) New(w http.ResponseWriter, r *http.Request) {
dc := captcha.NewDwellingCaptcha(h.ExpireIn) dc := captcha.NewDwellingCaptcha(captcha.GetExpireInterval())
_, id := captcha.New(r.RemoteAddr, dc) _, id := captcha.New(r.RemoteAddr, dc)
fmt.Fprint(w, id) fmt.Fprint(w, id)