change kontor-gin templates
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 3s

This commit is contained in:
Thomas Peetz
2026-09-24 16:06:38 +02:00
parent ba83d70764
commit 131296c644
26 changed files with 333 additions and 419 deletions
+32
View File
@@ -0,0 +1,32 @@
package globals
import (
"fmt"
"log/slog"
"strings"
"github.com/spf13/viper"
)
func InitConfig() error {
viper.SetConfigName("kontor-gin")
viper.SetConfigType("yaml")
viper.AddConfigPath(".")
viper.AddConfigPath("$HOME/.config")
viper.AddConfigPath("/etc/kontor")
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
viper.AutomaticEnv()
// Read the config file
if err := viper.ReadInConfig(); err != nil {
// Handle the case where config file is not found
if _, ok := err.(viper.ConfigFileNotFoundError); ok {
slog.Info("No config file found, using defaults")
return nil
}
return fmt.Errorf("error reading config file: %w", err)
}
slog.Info("initConfig", "Using config file: ", viper.ConfigFileUsed())
return nil
}
+1 -1
View File
@@ -6,6 +6,6 @@ const UserKey = "user"
const Version = "0.4.0"
const LoginUrl = "/auth/login"
const LoginUrl = "/login"
const LogoutUrl = "/auth/logout"