From 5587fdaaa8467b1008a76a3f893ba4243b445a8f Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Thu, 12 Dec 2024 16:30:46 +0100 Subject: [PATCH] feat(barcodes): Baseline for implementation --- handlers/barcode.go | 18 ++++++++++++++++++ main.go | 4 +--- 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 handlers/barcode.go diff --git a/handlers/barcode.go b/handlers/barcode.go new file mode 100644 index 0000000..12edfad --- /dev/null +++ b/handlers/barcode.go @@ -0,0 +1,18 @@ +package handlers + +import ( + "github.com/gofiber/fiber/v2" +) + +// GenerateBarcode godoc +// @Summary Generate barcodes +// @Description Generate barcodes based on the provided data +// @Tags barcodes +// @Param type path string true "Barcode type" Enums(ean13, code128) +// @Param content path string true "Barcode content" MinLength(1) +// @Produce image/png +// @Router /v1/barcodes/{type}/{content} [get] +func (h *DefaultHandler) GenerateBarcode(c *fiber.Ctx) error { + c.Set(fiber.HeaderContentType, "text/plain") + return c.Send([]byte("Hello, World!")) +} diff --git a/main.go b/main.go index ace4ed6..a0b2fd7 100644 --- a/main.go +++ b/main.go @@ -97,9 +97,7 @@ func main() { pdfv1.Post("/cards", handler.GenerateCard) pdfv1.Post("/certificates", handler.GenerateCertificate) - barcodev1 := v1.Group("/barcodes") - - barcodev1.Get("/:type/:content", handler.GenerateBarcode) + v1.Get("/barcodes/:type/:content", handler.GenerateBarcode) app.Use(handler.NotFoundHandler) docs.SwaggerInfo.BasePath = "/"