split http across files

This commit is contained in:
2026-04-11 23:04:50 +02:00
parent 4c87222b43
commit 59e693dacd
7 changed files with 1019 additions and 1005 deletions
+39
View File
@@ -0,0 +1,39 @@
package main
import "context"
func GetUserById(ctx context.Context, userId uint32) (*User, error) {
user, err := CacheGetUserById(userId)
if err != nil {
user = &User{Id: userId}
err = DbGetWholeUser(ctx, user)
if err != nil {
return nil, err
}
}
return user, nil
}
func GetUserByToken(ctx context.Context, token string) (*User, error) {
userId, err := TokenValidateGetId(token)
if err != nil {
return nil, err
}
return GetUserById(ctx, userId)
}
func GetGroup(ctx context.Context, groupId uint32) (*Group, error) {
group, err := CacheGetGroup(groupId)
if err != nil {
group = &Group{Id: groupId}
if err = DbGroupGetById(ctx, group); err != nil {
return nil, err
}
if err = DbGroupGetMembers(ctx, group); err != nil {
return nil, err
}
CacheSaveGroup(group)
}
return group, nil
}