Merge branch 'feature-status' into 'main'

Added Status codes

See merge request Phil/goshorly!2
This commit is contained in:
Phil 2021-12-08 17:27:50 +01:00
commit eef3069257

View file

@ -17,7 +17,7 @@ type eurl struct {
func Posthome(c *fiber.Ctx) error {
u := new(eurl)
if err := c.BodyParser(u); err != nil {
return c.Render("views/home", fiber.Map{
return c.Status(500).Render("views/home", fiber.Map{
"ERR": "Parsing Error",
"GitCommitShort": utils.GitCommitShort,
"GitBranch": utils.GitBranch,
@ -26,7 +26,7 @@ func Posthome(c *fiber.Ctx) error {
}
if !regexp.MustCompile(`^(http|https|mailto|ts3server)://`).MatchString(u.URL) {
return c.Render("views/home", fiber.Map{
return c.Status(424).Render("views/home", fiber.Map{
"ERR": "Invalid URL, please check and try again.",
"GitCommitShort": utils.GitCommitShort,
"GitBranch": utils.GitBranch,
@ -37,7 +37,7 @@ func Posthome(c *fiber.Ctx) error {
id, err := gonanoid.New(8)
if err != nil {
return c.Render("views/home", fiber.Map{
return c.Status(500).Render("views/home", fiber.Map{
"ERR": err.Error(),
"GitCommitShort": utils.GitCommitShort,
"GitBranch": utils.GitBranch,
@ -48,7 +48,7 @@ func Posthome(c *fiber.Ctx) error {
err = db.Client.Set(id, u.URL, 1296000*time.Second).Err()
if err != nil {
return c.Render("views/home", fiber.Map{
return c.Status(500).Render("views/home", fiber.Map{
"ERR": err.Error(),
"GitCommitShort": utils.GitCommitShort,
"GitBranch": utils.GitBranch,
@ -58,7 +58,7 @@ func Posthome(c *fiber.Ctx) error {
fURL := utils.URL + id
return c.Render("views/home", fiber.Map{
return c.Status(201).Render("views/home", fiber.Map{
"URL": fURL,
"GitCommitShort": utils.GitCommitShort,
"GitBranch": utils.GitBranch,