feat: migrate playback domain to modular architecture

This commit is contained in:
2026-05-13 11:20:46 +02:00
parent ab31cf4c4c
commit 4d1fd2834b
5 changed files with 205 additions and 33 deletions

View File

@@ -4,13 +4,12 @@ import (
"context"
"net/http"
"mal/api/auth"
"mal/internal/domain"
ctxpkg "mal/internal/context"
"mal/internal/db"
)
// Auth middleware validates the session cookie and injects the user into context
func Auth(authService *auth.Service) func(http.Handler) http.Handler {
func Auth(authService domain.AuthService) func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
cookie, err := r.Cookie("session_id")
@@ -32,8 +31,8 @@ func Auth(authService *auth.Service) func(http.Handler) http.Handler {
}
// GetUser retrieves the authenticated user from context, or nil if not authenticated
func GetUser(ctx context.Context) *db.User {
user, ok := ctx.Value(ctxpkg.UserKey).(*db.User)
func GetUser(ctx context.Context) *domain.User {
user, ok := ctx.Value(ctxpkg.UserKey).(*domain.User)
if !ok {
return nil
}