diff --git a/main.go b/main.go index 6ee7323..8b3f9aa 100644 --- a/main.go +++ b/main.go @@ -15,10 +15,22 @@ import ( "github.com/rs/zerolog/log" ) +// Logic Jellyfin URL type Logic struct { BaseURL string } +// PublicInfo Chromecast configuration Payload +type PublicInfo struct { + ID string + LocalAddress string + OperatingSystem string + ProductName string + ServerName string + StartupWizardCompleted bool + Version string +} + func (l Logic) ServeHTTP(w http.ResponseWriter, r *http.Request) { logger := logginghandler.Logger(r) @@ -50,24 +62,15 @@ func (l Logic) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } - jd := map[string]string{} + var jd PublicInfo if err := json.Unmarshal(body, &jd); err != nil { logger.Error().Msg(err.Error()) http.Error(w, "could not unmarshal body", http.StatusInternalServerError) return } - - // Delete LocalAddress from map. - _, ok := jd["LocalAddress"] - if ok { - delete(jd, "LocalAddress") - } else { - logger.Debug().Msg("nothing to do") - - return - } - + url := os.Getenv("JELLYFIN_URL") + jd.LocalAddress = url nd, err := json.Marshal(jd) if err != nil { logger.Error().Msg(err.Error()) @@ -91,6 +94,7 @@ func main() { l := Logic{BaseURL: os.Args[1]} handler := logginghandler.Handler(l) + http.Handle("/", handler) log.Info().Msg("starting server...") log.Fatal().Msg(http.ListenAndServe("0.0.0.0:8088", nil).Error()) diff --git a/vendor/github.com/rs/zerolog/go.mod b/vendor/github.com/rs/zerolog/go.mod index 340ed40..acba195 100644 --- a/vendor/github.com/rs/zerolog/go.mod +++ b/vendor/github.com/rs/zerolog/go.mod @@ -1,5 +1,7 @@ module github.com/rs/zerolog +go 1.15 + require ( github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e github.com/pkg/errors v0.8.1