Use MustGetText to get the company’s slug

This commit is contained in:
jordi fita mas 2023-02-03 10:51:48 +01:00
parent 917db31227
commit 80f14d5818
1 changed files with 1 additions and 5 deletions

View File

@ -25,11 +25,7 @@ func NewRouter(db *Db) http.Handler {
user := getUser(r) user := getUser(r)
if user.LoggedIn { if user.LoggedIn {
conn := getConn(r) conn := getConn(r)
var slug string slug := conn.MustGetText(r.Context(), "", "select slug::text from company order by company_id limit 1")
err := conn.QueryRow(r.Context(), "select slug::text from company order by company_id limit 1").Scan(&slug)
if err != nil {
panic(err)
}
http.Redirect(w, r, "/company/"+slug, http.StatusFound) http.Redirect(w, r, "/company/"+slug, http.StatusFound)
} else { } else {
http.Redirect(w, r, "/login", http.StatusSeeOther) http.Redirect(w, r, "/login", http.StatusSeeOther)