Phase 2: Subsonic REST API framework (auth, response formatting, error handling, routing) plus user permission model

This commit is contained in:
2026-08-22 23:58:54 -05:00
parent f81c8704a5
commit b5e2bf01e2
26 changed files with 1772 additions and 75 deletions
+39
View File
@@ -0,0 +1,39 @@
package subsonic
import (
"database/sql"
"log/slog"
"net/http"
"git.noroutes.net/NoRoutes/vibetunes/internal/config"
"git.noroutes.net/NoRoutes/vibetunes/internal/coverart"
"git.noroutes.net/NoRoutes/vibetunes/internal/database"
"git.noroutes.net/NoRoutes/vibetunes/internal/scanner"
)
// Server holds every dependency the Subsonic REST API needs. It mirrors
// internal/web.Web's role for the browser UI: a thin adapter, not a
// second copy of the domain logic in internal/database/internal/library/
// internal/scanner/internal/streaming/internal/coverart.
type Server struct {
DB *sql.DB
Config config.Config
EncryptionKey []byte
Scanner *scanner.Scanner
CoverArt *coverart.Store
Log *slog.Logger
}
// Context carries one request's parsed parameters, resolved user, and
// output format through a handler.
type Context struct {
W http.ResponseWriter
R *http.Request
Server *Server
User *database.User
Params params
Format string
Callback string
Response *Response // set by success handlers; ignored if Handled is true
Handled bool // true if the handler already wrote the response itself (streaming endpoints)
}