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)
if user.LoggedIn {
conn := getConn(r)
var slug string
err := conn.QueryRow(r.Context(), "select slug::text from company order by company_id limit 1").Scan(&slug)
if err != nil {
panic(err)
}
slug := conn.MustGetText(r.Context(), "", "select slug::text from company order by company_id limit 1")
http.Redirect(w, r, "/company/"+slug, http.StatusFound)
} else {
http.Redirect(w, r, "/login", http.StatusSeeOther)