42 lines
1.3 KiB
Go
42 lines
1.3 KiB
Go
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"
|
|
"git.noroutes.net/NoRoutes/vibetunes/internal/transcoding"
|
|
)
|
|
|
|
// 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
|
|
Transcoder *transcoding.Manager
|
|
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)
|
|
}
|