mirror of
https://github.com/yanislav-igonin/micrach
synced 2024-12-23 06:42:33 +03:00
24 lines
447 B
Go
24 lines
447 B
Go
|
package controllers
|
||
|
|
||
|
import (
|
||
|
"bytes"
|
||
|
"log"
|
||
|
"net/http"
|
||
|
|
||
|
"github.com/dchest/captcha"
|
||
|
"github.com/gin-gonic/gin"
|
||
|
)
|
||
|
|
||
|
func GetCaptcha(c *gin.Context) {
|
||
|
ID := c.Param("captchaID")
|
||
|
var content bytes.Buffer
|
||
|
err := captcha.WriteImage(&content, ID, captcha.StdWidth, captcha.StdHeight)
|
||
|
if err != nil {
|
||
|
log.Println("error:", err)
|
||
|
c.HTML(http.StatusInternalServerError, "500.html", nil)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
c.Data(200, "image/png", content.Bytes())
|
||
|
}
|