Phase 2: Subsonic REST API framework (auth, response formatting, error handling, routing) plus user permission model
This commit is contained in:
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user