Go-based FM stereo transmitter with RDS, Windows-first and cross-platform
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

38 Zeilen
999B

  1. package control
  2. import (
  3. "encoding/json"
  4. "net/http"
  5. "github.com/jan/fm-rds-tx/internal/config"
  6. )
  7. type Server struct {
  8. cfg config.Config
  9. }
  10. func NewServer(cfg config.Config) *Server { return &Server{cfg: cfg} }
  11. func (s *Server) Handler() http.Handler {
  12. mux := http.NewServeMux()
  13. mux.HandleFunc("/healthz", s.handleHealth)
  14. mux.HandleFunc("/status", s.handleStatus)
  15. return mux
  16. }
  17. func (s *Server) handleHealth(w http.ResponseWriter, _ *http.Request) {
  18. w.Header().Set("Content-Type", "application/json")
  19. _ = json.NewEncoder(w).Encode(map[string]any{"ok": true})
  20. }
  21. func (s *Server) handleStatus(w http.ResponseWriter, _ *http.Request) {
  22. w.Header().Set("Content-Type", "application/json")
  23. _ = json.NewEncoder(w).Encode(map[string]any{
  24. "service": "fm-rds-tx",
  25. "backend": s.cfg.Backend.Kind,
  26. "frequencyMHz": s.cfg.FM.FrequencyMHz,
  27. "stereoEnabled": s.cfg.FM.StereoEnabled,
  28. "rdsEnabled": s.cfg.RDS.Enabled,
  29. })
  30. }