feat(authentication): Added authentication controller & JWTMiddleware
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user