Skip to content

Commit

Permalink
fix: Logger variable not found
Browse files Browse the repository at this point in the history
  • Loading branch information
Hamza12700 committed Oct 27, 2024
1 parent bab4859 commit 48c6478
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions handlers/redirect.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,21 @@ import (
"github.com/wavly/shawty/asserts"
. "github.com/wavly/shawty/cache"
"github.com/wavly/shawty/internal/database"
prettylogger "github.com/wavly/shawty/pretty-logger"
"github.com/wavly/shawty/utils"
"github.com/wavly/shawty/validate"
)

var Logger = prettylogger.GetLogger(nil)

func Redirect(w http.ResponseWriter, r *http.Request) {
code := r.PathValue("code")

// Validate the code
err := validate.CustomCodeValidate(code)
if err != nil {
Logger.Warn("Code validation failed", "code", code, "user-agent", r.UserAgent())
http.Redirect(w, r, "/", http.StatusBadRequest)
Logger.Warn("Code validation failed", "code", code, "user-agent", r.UserAgent(), "error", err)
http.Redirect(w, r, "/", http.StatusSeeOther)
return
}

Expand Down

0 comments on commit 48c6478

Please sign in to comment.