- Go web server using Gin framework - Proxy FRED economic data API - Support series, observations, search, releases endpoints
35 lines
516 B
Go
35 lines
516 B
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
)
|
|
|
|
type Config struct {
|
|
FREDAPIKey string
|
|
ServerPort string
|
|
FREDBaseURL string
|
|
}
|
|
|
|
func Load() *Config {
|
|
apiKey := os.Getenv("FRED_API_KEY")
|
|
if apiKey == "" {
|
|
apiKey = "987b9c3428a3d0fe90179e3e6298d05e"
|
|
}
|
|
|
|
port := os.Getenv("SERVER_PORT")
|
|
if port == "" {
|
|
port = "8080"
|
|
}
|
|
|
|
baseURL := os.Getenv("FRED_BASE_URL")
|
|
if baseURL == "" {
|
|
baseURL = "https://api.stlouisfed.org/fred"
|
|
}
|
|
|
|
return &Config{
|
|
FREDAPIKey: apiKey,
|
|
ServerPort: port,
|
|
FREDBaseURL: baseURL,
|
|
}
|
|
}
|