Refractor Codebase

This commit is contained in:
Phil 2023-04-05 22:29:43 +02:00
parent c98abe116e
commit a2d2d4c9f0
2 changed files with 18 additions and 33 deletions

View file

@ -11,33 +11,28 @@ import (
func ID(c *fiber.Ctx) error {
val, err := db.Get(c.Params("id"))
if c.Get("CLI") == "1" {
if err != nil {
if c.Get("CLI") == "1" {
return c.Status(404).JSON(&fiber.Map{
"error": true,
"url": "URL not found",
})
} else {
return c.Render("views/404", fiber.Map{
"BASEURL": utils.URL,
})
}
}
_, err = db.StatsIncreaseViewsLinks()
if err != nil {
log.Fatal(err.Error())
}
if c.Get("CLI") == "1" {
return c.Status(301).JSON(&fiber.Map{
"error": false,
"url": val,
})
}
}
if err != nil {
return c.Render("views/404", fiber.Map{
"BASEURL": utils.URL,
})
}
_, err = db.StatsIncreaseViewsLinks()
if err != nil {
log.Fatal(err.Error())
}
return c.Redirect(val)
}

View file

@ -14,27 +14,17 @@ var (
)
func Init_build_vars() {
if CI_COMMIT_SHORT_SHA == "" && CI_COMMIT_BRANCH == "" {
CI_BUILD = false
} else {
CI_BUILD = true
}
if CI_COMMIT_TAG == "" {
CI_TAGGED = false
} else {
CI_TAGGED = true
}
CI_BUILD = CI_COMMIT_SHORT_SHA != "" || CI_COMMIT_BRANCH != ""
CI_TAGGED = CI_COMMIT_TAG != ""
}
func Print_Starting_Screen() {
if CI_BUILD {
version := "unknown version"
if CI_TAGGED {
fmt.Println("---- Starting goshorly " + CI_COMMIT_TAG + " ----")
} else {
fmt.Println("---- Starting goshorly " + CI_COMMIT_SHORT_SHA + " ----")
}
} else {
fmt.Println("---- Starting goshorly " + "unknown version" + " ----")
version = CI_COMMIT_TAG
} else if CI_BUILD {
version = CI_COMMIT_SHORT_SHA
}
fmt.Println("---- Starting goshorly " + version + " ----")
time.Sleep(1 * time.Second)
}