mirror of
https://github.com/yanislav-igonin/micrach
synced 2024-12-22 14:22:33 +03:00
c8c9850625
* add fiber * disable gin, enable fiber * gradually enabling app setup * change env * add routes * add static * connect template engine * add simple load test * make it executable * add rate limiter * doc * connect get threads controller * clean * add compression middleware * add etag middleware * lint * add recover middleware * check isFromLocal method * connect get thread by id controller * connect create thread controller * connect captcha controller * connect update thread controller * rename file * playing with css * connect gateway controller
23 lines
482 B
Go
23 lines
482 B
Go
package controllers
|
|
|
|
import (
|
|
"bytes"
|
|
"log"
|
|
|
|
"github.com/dchest/captcha"
|
|
"github.com/gofiber/fiber/v2"
|
|
)
|
|
|
|
func GetCaptcha(c *fiber.Ctx) error {
|
|
ID := c.Params("captchaID")
|
|
var content bytes.Buffer
|
|
err := captcha.WriteImage(&content, ID, captcha.StdWidth, captcha.StdHeight)
|
|
if err != nil {
|
|
log.Println("error:", err)
|
|
return c.Status(fiber.StatusInternalServerError).Render("pages/500", nil)
|
|
}
|
|
|
|
c.Context().SetContentType("image/png")
|
|
return c.Send(content.Bytes())
|
|
}
|