Error page + config + docker

This commit is contained in:
William Bouzourène 2026-02-16 14:58:18 +01:00
parent 7e821296a6
commit c6c533a503
Signed by: bouzoure
GPG key ID: 423440D735B56BE2
13 changed files with 110 additions and 31 deletions

View file

@ -16,12 +16,12 @@ func Fetch(c *fiber.Ctx) error {
baseParams := templates.BaseTemplateParams{
Title: "Error - GPX downloader",
}
var indexParams templates.IndexParams
var errorParams templates.ErrorParams
sourceUrl := c.FormValue("url")
if len(sourceUrl) <= 0 {
indexParams.Error = "Error: URL is empty"
return helpers.TemplRender(c, templates.Index(baseParams, indexParams))
errorParams.Error = "Error: URL is empty"
return helpers.TemplRender(c, templates.Error(baseParams, errorParams))
}
var gpxFile gpx.GPX
@ -39,21 +39,21 @@ func Fetch(c *fiber.Ctx) error {
gpxFile, err = providers.SuisseMobileFetch(suisseMobileId)
if err != nil {
log.Error(err)
indexParams.Error = "An error occured"
return helpers.TemplRender(c, templates.Index(baseParams, indexParams))
errorParams.Error = "An error occured"
return helpers.TemplRender(c, templates.Error(baseParams, errorParams))
}
}
if len(filename) <= 0 {
indexParams.Error = "Error: URL is not supported"
return helpers.TemplRender(c, templates.Index(baseParams, indexParams))
errorParams.Error = "Error: URL is not supported"
return helpers.TemplRender(c, templates.Error(baseParams, errorParams))
}
xml, err := gpxFile.ToXml(gpx.ToXmlParams{})
if err != nil {
log.Error(err)
indexParams.Error = "An error occured"
return helpers.TemplRender(c, templates.Index(baseParams, indexParams))
errorParams.Error = "An error occured"
return helpers.TemplRender(c, templates.Error(baseParams, errorParams))
}
c.Set("Content-Type", "octet-stream")

View file

@ -10,7 +10,6 @@ func Index(c *fiber.Ctx) error {
baseParams := templates.BaseTemplateParams{
Title: "GPX downloader",
}
var indexParams templates.IndexParams
return helpers.TemplRender(c, templates.Index(baseParams, indexParams))
return helpers.TemplRender(c, templates.Index(baseParams))
}