From 6ca796efb6e94e89db923d287ce29593bb0c2e6a Mon Sep 17 00:00:00 2001 From: Dmitrii Andreev Date: Sun, 13 Apr 2025 08:15:23 +0300 Subject: [PATCH] renamed some config options --- README.md | 16 ++++++++-------- internal/config/config.go | 8 ++++---- internal/rss/rss.go | 2 +- internal/server/server.go | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 7871ce4..2107b88 100644 --- a/README.md +++ b/README.md @@ -44,14 +44,14 @@ go build -o icecast-ripper ./cmd/icecast-ripper/main.go Icecast Ripper is configured through environment variables: | Environment Variable | Description | Default | Required | -|---------------------|-------------|---------|----------| -| `STREAM_URL` | URL of the Icecast stream to monitor | - | Yes | -| `CHECK_INTERVAL` | Interval between stream checks (e.g., 1m, 30s) | 1m | No | -| `RECORDINGS_PATH` | Path where recordings are stored | ./recordings | No | -| `TEMP_PATH` | Path for temporary files | ./temp | No | -| `SERVER_ADDRESS` | Address and port for the HTTP server | :8080 | No | -| `RSS_FEED_URL` | Public URL for the RSS feed | | No | -| `LOG_LEVEL` | Logging level (debug, info, warn, error) | info | No | +|----------------------|-------------|---------|----------| +| `STREAM_URL` | URL of the Icecast stream to monitor | - | Yes | +| `CHECK_INTERVAL` | Interval between stream checks (e.g., 1m, 30s) | 1m | No | +| `RECORDINGS_PATH` | Path where recordings are stored | ./recordings | No | +| `TEMP_PATH` | Path for temporary files | ./temp | No | +| `BIND_ADDRESS` | Address and port for the HTTP server | :8080 | No | +| `PUBLIC_URL` | Public URL for the RSS feed | | No | +| `LOG_LEVEL` | Logging level (debug, info, warn, error) | info | No | ## Docker Compose diff --git a/internal/config/config.go b/internal/config/config.go index afc1103..12f8c55 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -12,8 +12,8 @@ type Config struct { CheckInterval time.Duration `mapstructure:"CHECK_INTERVAL"` RecordingsPath string `mapstructure:"RECORDINGS_PATH"` TempPath string `mapstructure:"TEMP_PATH"` - ServerAddress string `mapstructure:"SERVER_ADDRESS"` - RSSFeedURL string `mapstructure:"RSS_FEED_URL"` + BindAddress string `mapstructure:"BIND_ADDRESS"` + PublicUrl string `mapstructure:"PUBLIC_URL"` LogLevel string `mapstructure:"LOG_LEVEL"` } @@ -28,8 +28,8 @@ func LoadConfig() (*Config, error) { "CHECK_INTERVAL": "1m", "RECORDINGS_PATH": "./recordings", "TEMP_PATH": "/tmp", - "SERVER_ADDRESS": ":8080", - "RSS_FEED_URL": "http://localhost:8080/rss", + "BIND_ADDRESS": ":8080", + "PUBLIC_URL": "http://localhost:8080", "LOG_LEVEL": "info", } diff --git a/internal/rss/rss.go b/internal/rss/rss.go index 9e2ba66..89edd5f 100644 --- a/internal/rss/rss.go +++ b/internal/rss/rss.go @@ -35,7 +35,7 @@ type Generator struct { // New creates a new RSS Generator instance func New(cfg *config.Config, title, description, streamName string) *Generator { - baseURL := cfg.RSSFeedURL + baseURL := cfg.PublicUrl if baseURL == "" { slog.Warn("RSS_FEED_URL not set, using default") baseURL = "http://localhost:8080/recordings/" diff --git a/internal/server/server.go b/internal/server/server.go index c3a66fd..b33043c 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -45,7 +45,7 @@ func New(cfg *config.Config, rssGenerator *rss.Generator) *Server { // Configure server with sensible timeouts s.server = &http.Server{ - Addr: cfg.ServerAddress, + Addr: cfg.BindAddress, Handler: mux, ReadTimeout: 10 * time.Second, WriteTimeout: 10 * time.Second, @@ -56,7 +56,7 @@ func New(cfg *config.Config, rssGenerator *rss.Generator) *Server { } // handleRSS generates and serves the RSS feed -func (s *Server) handleRSS(w http.ResponseWriter, r *http.Request) { +func (s *Server) handleRSS(w http.ResponseWriter, _ *http.Request) { slog.Debug("Serving RSS feed") const maxItems = 50