refactor(config): Load gotenberg url from env

This commit is contained in:
Nicolai Ort 2024-12-11 18:45:53 +01:00
parent 4faf76a073
commit 41291b9200
Signed by: niggl
GPG Key ID: 13AFA55AF62F269F
5 changed files with 5 additions and 3 deletions

1
.env
View File

@ -3,6 +3,7 @@ PRODUCION=false
APIKEY=lfk
EVENTNAME=Lauf für Kaya! 2025
CURRENCYSYMBOL=
GOTENBERG_BASEURL=http://localhost:3001
CARD_SUBTITLE=Kaya ist cool
CARD_BARCODEFORMAT=ean13

View File

@ -60,7 +60,7 @@ func (h *DefaultHandler) GenerateCard(c *fiber.Ctx) error {
})
}
c.Set(fiber.HeaderContentType, "text/html")
converter := services.GotenbergConverter{BaseUrl: "http://localhost:3001"}
converter := services.GotenbergConverter{BaseUrl: h.Config.GotenbergBaseUrl}
pdf, err := converter.ToPdf(result, "a4", false)
if err != nil {
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{

View File

@ -60,7 +60,7 @@ func (h *DefaultHandler) GenerateCertificate(c *fiber.Ctx) error {
})
}
c.Set(fiber.HeaderContentType, "text/html")
converter := services.GotenbergConverter{BaseUrl: "http://localhost:3001"}
converter := services.GotenbergConverter{BaseUrl: h.Config.GotenbergBaseUrl}
pdf, err := converter.ToPdf(result, "a4", false)
if err != nil {
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{

View File

@ -64,7 +64,7 @@ func (h *DefaultHandler) GenerateContract(c *fiber.Ctx) error {
})
}
converter := services.GotenbergConverter{BaseUrl: "http://localhost:3001"}
converter := services.GotenbergConverter{BaseUrl: h.Config.GotenbergBaseUrl}
pdf, err := converter.ToPdf(result, "a5", true)
if err != nil {
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{

View File

@ -14,4 +14,5 @@ type Config struct {
SponsoringBarcodeFormat string `mapstructure:"SPONSORING_BARCODEFORMAT"`
SponsoringBarcodePrefix string `mapstructure:"SPONSORING_BARCODEPREFIX"`
CertificateFooter string `mapstructure:"CERTIFICATE_FOOTER"`
GotenbergBaseUrl string `mapstructure:"GOTENBERG_BASEURL"`
}