refactor: Switch to pdf subpath
This commit is contained in:
parent
28de60d375
commit
8f676f08a9
@ -12,11 +12,11 @@ import (
|
|||||||
// GenerateCard godoc
|
// GenerateCard godoc
|
||||||
// @Summary Generate runner cards
|
// @Summary Generate runner cards
|
||||||
// @Description Generate cards based on the provided data
|
// @Description Generate cards based on the provided data
|
||||||
// @Tags cards
|
// @Tags pdfs
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param data body models.CardRequest true "Card data"
|
// @Param data body models.CardRequest true "Card data"
|
||||||
// @Produce application/pdf
|
// @Produce application/pdf
|
||||||
// @Router /cards [post]
|
// @Router /v1/pdfs/cards [post]
|
||||||
func (h *DefaultHandler) GenerateCard(c *fiber.Ctx) error {
|
func (h *DefaultHandler) GenerateCard(c *fiber.Ctx) error {
|
||||||
cardRequest := new(models.CardRequest)
|
cardRequest := new(models.CardRequest)
|
||||||
if err := c.BodyParser(cardRequest); err != nil {
|
if err := c.BodyParser(cardRequest); err != nil {
|
||||||
|
@ -12,11 +12,11 @@ import (
|
|||||||
// GenerateCertificate godoc
|
// GenerateCertificate godoc
|
||||||
// @Summary Generate runner certificates
|
// @Summary Generate runner certificates
|
||||||
// @Description Generate certificates based on the provided data
|
// @Description Generate certificates based on the provided data
|
||||||
// @Tags certificates
|
// @Tags pdfs
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param data body models.CertificateRequest true "Certificate data"
|
// @Param data body models.CertificateRequest true "Certificate data"
|
||||||
// @Produce application/pdf
|
// @Produce application/pdf
|
||||||
// @Router /certificates [post]
|
// @Router /v1/pdfs/certificates [post]
|
||||||
func (h *DefaultHandler) GenerateCertificate(c *fiber.Ctx) error {
|
func (h *DefaultHandler) GenerateCertificate(c *fiber.Ctx) error {
|
||||||
certificateRequest := new(models.CertificateRequest)
|
certificateRequest := new(models.CertificateRequest)
|
||||||
if err := c.BodyParser(certificateRequest); err != nil {
|
if err := c.BodyParser(certificateRequest); err != nil {
|
||||||
|
@ -12,11 +12,11 @@ import (
|
|||||||
// GenerateContract godoc
|
// GenerateContract godoc
|
||||||
// @Summary Generate a contract
|
// @Summary Generate a contract
|
||||||
// @Description Generate a contract based on the provided data
|
// @Description Generate a contract based on the provided data
|
||||||
// @Tags contracts
|
// @Tags pdfs
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Param data body models.ContractRequest true "Contract data"
|
// @Param data body models.ContractRequest true "Contract data"
|
||||||
// @Produce application/pdf
|
// @Produce application/pdf
|
||||||
// @Router /contracts [post]
|
// @Router /v1/pdfs/contracts [post]
|
||||||
func (h *DefaultHandler) GenerateContract(c *fiber.Ctx) error {
|
func (h *DefaultHandler) GenerateContract(c *fiber.Ctx) error {
|
||||||
contract := new(models.ContractRequest)
|
contract := new(models.ContractRequest)
|
||||||
if err := c.BodyParser(contract); err != nil {
|
if err := c.BodyParser(contract); err != nil {
|
||||||
|
19
main.go
19
main.go
@ -84,19 +84,22 @@ func main() {
|
|||||||
// Swagger documentation route
|
// Swagger documentation route
|
||||||
app.Get("/swagger/*", swagger.HandlerDefault)
|
app.Get("/swagger/*", swagger.HandlerDefault)
|
||||||
|
|
||||||
// @Security ApiKeyAuth
|
|
||||||
v1 := app.Group("/v1")
|
v1 := app.Group("/v1")
|
||||||
v1.Use(keyauth.New(keyauth.Config{
|
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
pdfv1 := v1.Group("/pdfs")
|
||||||
|
pdfv1.Use(keyauth.New(keyauth.Config{
|
||||||
KeyLookup: "query:key",
|
KeyLookup: "query:key",
|
||||||
Validator: validateAPIKey,
|
Validator: validateAPIKey,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
v1.Get("/", func(c *fiber.Ctx) error {
|
pdfv1.Post("/contracts", handler.GenerateContract)
|
||||||
return c.SendString("Hello, World!")
|
pdfv1.Post("/cards", handler.GenerateCard)
|
||||||
})
|
pdfv1.Post("/certificates", handler.GenerateCertificate)
|
||||||
v1.Post("/contracts", handler.GenerateContract)
|
|
||||||
v1.Post("/cards", handler.GenerateCard)
|
barcodev1 := v1.Group("/barcodes")
|
||||||
v1.Post("/certificates", handler.GenerateCertificate)
|
|
||||||
|
barcodev1.Get("/:type/:content", handler.GenerateBarcode)
|
||||||
|
|
||||||
app.Use(handler.NotFoundHandler)
|
app.Use(handler.NotFoundHandler)
|
||||||
docs.SwaggerInfo.BasePath = "/"
|
docs.SwaggerInfo.BasePath = "/"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user