Update vcard_qr.go
This commit is contained in:
@@ -249,39 +249,3 @@ func CreateUrlQr(c *fiber.Ctx) error {
|
||||
})
|
||||
}
|
||||
|
||||
func createCorreoQr(c *fiber.Ctx) error {
|
||||
var data struct {
|
||||
Correo string `json:"correo"`
|
||||
}
|
||||
if err := json.Unmarshal(c.Body(), &data); err != nil {
|
||||
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
|
||||
"error": "Datos inválidos",
|
||||
})
|
||||
}
|
||||
|
||||
qrBytes, err := services.GenerateCorreoQR(data.Correo)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
|
||||
"error": "No se pudo generar el QR",
|
||||
})
|
||||
}
|
||||
|
||||
img, err := png.Decode(bytes.NewReader(qrBytes))
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
|
||||
"error": "No se pudo procesar la imagen",
|
||||
})
|
||||
}
|
||||
|
||||
// Codificar a WebP
|
||||
var webpBuffer bytes.Buffer
|
||||
if err := webp.Encode(&webpBuffer, img, &webp.Options{Lossless: true}); err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
|
||||
"error": "No se pudo convertir a WebP",
|
||||
})
|
||||
}
|
||||
|
||||
c.Type("webp")
|
||||
return c.Send(webpBuffer.Bytes())
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user