Update vcard_qr.go

This commit is contained in:
lizandrogd
2025-06-11 02:20:17 -05:00
parent 30dfce6373
commit bf0abc65f1
-36
View File
@@ -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())
}