use servemux *properly* this time; better error handling for DB gets
This commit is contained in:
parent
a33e6717e0
commit
b7c1d85830
16 changed files with 234 additions and 288 deletions
|
|
@ -16,9 +16,7 @@ func GetInvite(db *sqlx.DB, code string) (*model.Invite, error) {
|
|||
|
||||
err := db.Get(&invite, "SELECT * FROM invite WHERE code=$1", code)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "no rows") {
|
||||
return nil, nil
|
||||
}
|
||||
if strings.Contains(err.Error(), "no rows") { return nil, nil }
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
|
@ -32,7 +30,7 @@ func CreateInvite(db *sqlx.DB, length int, lifetime time.Duration) (*model.Invit
|
|||
}
|
||||
|
||||
code := []byte{}
|
||||
for i := 0; i < length; i++ {
|
||||
for range length {
|
||||
code = append(code, inviteChars[rand.Intn(len(inviteChars) - 1)])
|
||||
}
|
||||
invite.Code = string(code)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue