GetAnswer() method changed into Answer().

This commit is contained in:
Alexander Andreev 2022-08-19 02:24:00 +04:00
parent c6bd1a6185
commit 4b0577f1bd
Signed by: Arav
GPG Key ID: 0388CC8FAA51063F
3 changed files with 4 additions and 4 deletions

View File

@ -42,7 +42,7 @@ func (c *DwellingCaptcha) Image(style string) *image.Image {
ctx.SetRGB255(0x0a, 0x0a, 0x0a)
}
ctx.Scale(4.0, 2.7)
ctx.DrawStringAnchored(string(c.GetAnswer()), 20, 5, .5, .5)
ctx.DrawStringAnchored(string(c.Answer()), 20, 5, .5, .5)
// draw lines and points
h := float64(ctx.Height())

View File

@ -23,7 +23,7 @@ type Captcha interface {
// Image generates and returns an image of captcha.
Image(style string) *image.Image
// GetAnswer returns a pregenerated answer.
GetAnswer() Answer
Answer() Answer
// Solve compares a stored answer with a passed one.
// Sets field Solved to true if they are equal.
Solve(answer Answer) bool
@ -53,7 +53,7 @@ func (c *BaseCaptcha) Image(style string) *image.Image {
return nil
}
func (c *BaseCaptcha) GetAnswer() Answer {
func (c *BaseCaptcha) Answer() Answer {
if c.answer == "" {
c.answer = NewIntAnswer()
}

View File

@ -65,7 +65,7 @@ func NewInMemoryCaptchaDB(expire time.Duration) *InMemoryCaptchaDB {
// `data` string is an additional random data used to generate an ID,
// e.g. IP-address.
func (cdb *InMemoryCaptchaDB) New(data string, captcha Captcha) (Captcha, ID) {
id := NewID(data, captcha.GetAnswer())
id := NewID(data, captcha.Answer())
cdb.Lock()
cdb.db[id] = captcha