add initial project structure with configuration, models, and API key authentication

This commit is contained in:
Flavio Fois
2026-03-17 12:21:48 +01:00
commit 08ff1da469
16 changed files with 379 additions and 0 deletions

34
internal/config/config.go Normal file
View File

@@ -0,0 +1,34 @@
package config
import (
"os"
"strings"
)
type Config struct {
Port string
DSN string
APIKeys []string
}
func Load() *Config {
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}
raw := os.Getenv("API_KEYS")
var keys []string
for _, k := range strings.Split(raw, ",") {
k = strings.TrimSpace(k)
if k != "" {
keys = append(keys, k)
}
}
return &Config{
Port: port,
DSN: os.Getenv("DB_DSN"),
APIKeys: keys,
}
}