micrach/controllers/captcha_controller.go
Yanislav Igonin fbe39f45a3
Feature - Components refactor (#10)
* feat: header component

* feat: captcha component

* feat: rename all html files

* feat: update github link

* feat: all templates in subfolders

* feat: separate thread card

* feat: separate pagination

* feat: update pagination

* feat: separate post

* lint
2022-01-31 19:56:21 +03:00

24 lines
453 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, "pages/500.html", nil)
return
}
c.Data(200, "image/png", content.Bytes())
}