navidrome/server/apiv1/server_handlers.go
Deluan cbc22b09cb refactor(api): group API v1 handlers into one file per OpenAPI tag
Handlers live in <tag>_handlers.go, so the package grows by tag rather than
by endpoint, and shared convention helpers keep plain names without
clashing with tag files.

Signed-off-by: Deluan <deluan@navidrome.org>
2026-09-28 22:08:01 -04:00

30 lines
861 B
Go

package apiv1
import (
"context"
"fmt"
"github.com/navidrome/navidrome/api"
"github.com/navidrome/navidrome/consts"
)
func (rt *Router) GetServerInfo(ctx context.Context, _ GetServerInfoRequestObject) (GetServerInfoResponseObject, error) {
count, err := rt.ds.User().CountAll(ctx)
if err != nil {
return nil, fmt.Errorf("counting users: %w", err)
}
return GetServerInfo200JSONResponse{
Name: "Navidrome",
ServerVersion: consts.Version,
SpecVersion: api.SpecVersion(),
SetupRequired: count == 0,
LoginMethods: LoginMethods{Password: &PasswordLoginMethod{}},
}, nil
}
func (rt *Router) GetCapabilities(context.Context, GetCapabilitiesRequestObject) (GetCapabilitiesResponseObject, error) {
return GetCapabilities200JSONResponse{
Core: &CoreCapability{Version: 1},
Password: &PasswordCapability{Version: 1},
}, nil
}