Adding function signatures for API handlers

Signed-off-by: Ethan Wellenreiter <ewellenreiter@gmail.com>
This commit is contained in:
Ethan Wellenreiter 2025-06-23 13:11:16 -04:00
parent 9b9305db29
commit a22bbbf5ab
2 changed files with 33 additions and 5 deletions

View File

@ -9,8 +9,12 @@ import (
"github.com/go-chi/chi/v5"
)
type groupKey string
const groupCtx groupKey = "group"
func (app *application) getUserGroups(ctx context.Context, userID int64) (*storage.UserGroups, error) {
if !app.config.redisCfg.enabled {
if !app.config.cacheCfg.enabled {
return app.store.Groups.GetUserGroups(ctx, userID)
}
@ -34,7 +38,7 @@ func (app *application) getUserGroups(ctx context.Context, userID int64) (*stora
}
func (app *application) getGroup(ctx context.Context, groupID int64) (*storage.Group, error) {
if !app.config.redisCfg.enabled {
if !app.config.cacheCfg.enabled {
return app.store.Groups.GetByID(ctx, groupID)
}
@ -104,3 +108,24 @@ func (app *application) getUsersGroupHandler(w http.ResponseWriter, r *http.Requ
app.internalServerError(w, r, err)
}
}
func (app *application) setGroupOwnerHandler(w http.ResponseWriter, r *http.Request) {
}
func (app *application) getGroupOwnerHandler(w http.ResponseWriter, r *http.Request) {
}
func (app *application) addGroupModeratorHandler(w http.ResponseWriter, r *http.Request) {
}
func (app *application) removeModeratorPriviligesHandler(w http.ResponseWriter, r *http.Request) {
}
func (app *application) getGroupUsersHandler(w http.ResponseWriter, r *http.Request) {
}
func (app *application) addGroupUserHandler(w http.ResponseWriter, r *http.Request) {
}
func (app *application) removeUserFromGroupHandler(w http.ResponseWriter, r *http.Request) {
}

View File

@ -51,9 +51,12 @@ func (app *application) getUsersHandler(w http.ResponseWriter, r *http.Request)
func (app *application) deleteUserHandler(w http.ResponseWriter, r *http.Request) {
}
func (app *application) removeUserGroupHandler(w http.ResponseWriter, r *http.Request) {
}
func (app *application) getUser(ctx context.Context, userID int64) (*storage.User, error) {
if !app.config.redisCfg.enabled {
return app.auth.Users.GetByID(ctx, userID)
if !app.config.cacheCfg.enabled {
return app.store.Users.GetByID(ctx, userID)
}
user, err := app.cacheStorage.Users.Get(ctx, userID)
@ -62,7 +65,7 @@ func (app *application) getUser(ctx context.Context, userID int64) (*storage.Use
}
if user == nil {
user, err = app.auth.Users.GetByID(ctx, userID)
user, err = app.store.Users.GetByID(ctx, userID)
if err != nil {
return nil, err
}