mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-04 00:15:28 +08:00
37 lines
1.3 KiB
Go
37 lines
1.3 KiB
Go
package admin
|
|
|
|
import (
|
|
"net/http"
|
|
"strings"
|
|
|
|
authn "ds2api/internal/auth"
|
|
"ds2api/internal/config"
|
|
)
|
|
|
|
func (h *Handler) getSettings(w http.ResponseWriter, _ *http.Request) {
|
|
snap := h.Store.Snapshot()
|
|
recommended := defaultRuntimeRecommended(len(snap.Accounts), h.Store.RuntimeAccountMaxInflight())
|
|
needsSync := config.IsVercel() && snap.VercelSyncHash != "" && snap.VercelSyncHash != h.computeSyncHash()
|
|
writeJSON(w, http.StatusOK, map[string]any{
|
|
"success": true,
|
|
"admin": map[string]any{
|
|
"has_password_hash": strings.TrimSpace(snap.Admin.PasswordHash) != "",
|
|
"jwt_expire_hours": h.Store.AdminJWTExpireHours(),
|
|
"jwt_valid_after_unix": snap.Admin.JWTValidAfterUnix,
|
|
"default_password_warning": authn.UsingDefaultAdminKey(h.Store),
|
|
},
|
|
"runtime": map[string]any{
|
|
"account_max_inflight": h.Store.RuntimeAccountMaxInflight(),
|
|
"account_max_queue": h.Store.RuntimeAccountMaxQueue(recommended),
|
|
"global_max_inflight": h.Store.RuntimeGlobalMaxInflight(recommended),
|
|
},
|
|
"toolcall": snap.Toolcall,
|
|
"responses": snap.Responses,
|
|
"embeddings": snap.Embeddings,
|
|
"claude_mapping": settingsClaudeMapping(snap),
|
|
"model_aliases": snap.ModelAliases,
|
|
"env_backed": h.Store.IsEnvBacked(),
|
|
"needs_vercel_sync": needsSync,
|
|
})
|
|
}
|