Go-based FM stereo transmitter with RDS, Windows-first and cross-platform
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 line
910B

  1. package control
  2. import (
  3. "net/http"
  4. "time"
  5. "github.com/jan/fm-rds-tx/internal/config"
  6. )
  7. const (
  8. defaultReadHeaderTimeout = 5 * time.Second
  9. defaultIdleTimeout = 60 * time.Second
  10. defaultMaxHeaderBytes = 1 << 20 // 1 MiB
  11. )
  12. // NewHTTPServer returns a configured HTTP server for the control plane.
  13. //
  14. // WriteTimeout is intentionally not set: /audio/stream accepts long-lived
  15. // POST bodies (continuous PCM push) that would be cut off by a global write
  16. // deadline. Individual endpoints are protected by MaxBytesReader limits.
  17. // ReadHeaderTimeout guards against slow-header attacks.
  18. func NewHTTPServer(cfg config.Config, handler http.Handler) *http.Server {
  19. return &http.Server{
  20. Addr: cfg.Control.ListenAddress,
  21. Handler: handler,
  22. ReadHeaderTimeout: defaultReadHeaderTimeout,
  23. IdleTimeout: defaultIdleTimeout,
  24. MaxHeaderBytes: defaultMaxHeaderBytes,
  25. }
  26. }