refactor: extract DefaultAuthDir constant per review feedback
This commit is contained in:
@@ -22,6 +22,7 @@ import (
|
|||||||
const (
|
const (
|
||||||
DefaultPanelGitHubRepository = "https://github.com/router-for-me/Cli-Proxy-API-Management-Center"
|
DefaultPanelGitHubRepository = "https://github.com/router-for-me/Cli-Proxy-API-Management-Center"
|
||||||
DefaultPprofAddr = "127.0.0.1:8316"
|
DefaultPprofAddr = "127.0.0.1:8316"
|
||||||
|
DefaultAuthDir = "~/.cli-proxy-api"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config represents the application's configuration, loaded from a YAML file.
|
// Config represents the application's configuration, loaded from a YAML file.
|
||||||
|
|||||||
@@ -73,9 +73,10 @@ func SetLogLevel(cfg *config.Config) {
|
|||||||
|
|
||||||
// ResolveAuthDir normalizes the auth directory path for consistent reuse throughout the app.
|
// ResolveAuthDir normalizes the auth directory path for consistent reuse throughout the app.
|
||||||
// It expands a leading tilde (~) to the user's home directory and returns a cleaned path.
|
// It expands a leading tilde (~) to the user's home directory and returns a cleaned path.
|
||||||
|
// If authDir is empty, it defaults to ~/.cli-proxy-api.
|
||||||
func ResolveAuthDir(authDir string) (string, error) {
|
func ResolveAuthDir(authDir string) (string, error) {
|
||||||
if authDir == "" {
|
if authDir == "" {
|
||||||
authDir = "~/.cli-proxy-api"
|
authDir = config.DefaultAuthDir
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(authDir, "~") {
|
if strings.HasPrefix(authDir, "~") {
|
||||||
home, err := os.UserHomeDir()
|
home, err := os.UserHomeDir()
|
||||||
|
|||||||
Reference in New Issue
Block a user