feat(authentication): Added authentication controller & JWTMiddleware

This commit is contained in:
2026-05-28 17:58:20 +03:30
parent bdb2fcc68f
commit 0b4cb868e7
9 changed files with 603 additions and 64 deletions
+10
View File
@@ -75,6 +75,9 @@ type Config struct {
// Database Related configurations
DatabaseURL string `env:"DATABASE_URL"`
// ENV
JWTSecret string `env:"JWT_SECRET"`
}
var Default = Config{
@@ -117,6 +120,9 @@ var Default = Config{
// Load loads the configuration from the environment. If a .env file is
// available, it will be loaded as well. Values found in the environment
// will overwrite whatever is load from the .env file.
var CachedConfig *Config
func Load() (*Config, error) {
envVars := make(map[string]string)
@@ -176,5 +182,9 @@ func Load() (*Config, error) {
}
config.RootPath = strings.Trim(config.RootPath, "/")
if CachedConfig == nil {
CachedConfig = &config
}
return &config, nil
}