Error page + config + docker
This commit is contained in:
parent
7e821296a6
commit
c6c533a503
13 changed files with 110 additions and 31 deletions
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue