(w http.ResponseWriter, r *http.Request)
| 241 | } |
| 242 | |
| 243 | func Index(w http.ResponseWriter, r *http.Request) { |
| 244 | var err error |
| 245 | var response []byte |
| 246 | var path = r.URL.Path |
| 247 | |
| 248 | systemMutex.Lock() |
| 249 | if Settings.HttpThreadfinDomain != "" { |
| 250 | setGlobalDomain(getBaseUrl(Settings.HttpThreadfinDomain, Settings.Port)) |
| 251 | } else { |
| 252 | setGlobalDomain(r.Host) |
| 253 | } |
| 254 | systemMutex.Unlock() |
| 255 | |
| 256 | switch path { |
| 257 | case "/discover.json": |
| 258 | response, err = getDiscover() |
| 259 | w.Header().Set("Content-Type", "application/json") |
| 260 | case "/lineup_status.json": |
| 261 | response, err = getLineupStatus() |
| 262 | w.Header().Set("Content-Type", "application/json") |
| 263 | case "/lineup.json": |
| 264 | systemMutex.Lock() |
| 265 | if Settings.AuthenticationPMS { |
| 266 | systemMutex.Unlock() |
| 267 | _, err := basicAuth(r, "authentication.pms") |
| 268 | if err != nil { |
| 269 | ShowError(err, 000) |
| 270 | httpStatusError(w, r, 403) |
| 271 | return |
| 272 | } |
| 273 | } else { |
| 274 | systemMutex.Unlock() |
| 275 | } |
| 276 | response, err = getLineup() |
| 277 | w.Header().Set("Content-Type", "application/json") |
| 278 | case "/device.xml", "/capability": |
| 279 | response, err = getCapability() |
| 280 | w.Header().Set("Content-Type", "application/xml") |
| 281 | default: |
| 282 | response, err = getCapability() |
| 283 | w.Header().Set("Content-Type", "application/xml") |
| 284 | } |
| 285 | |
| 286 | if err == nil { |
| 287 | w.WriteHeader(200) |
| 288 | w.Write(response) |
| 289 | return |
| 290 | } |
| 291 | |
| 292 | httpStatusError(w, r, 500) |
| 293 | return |
| 294 | } |
| 295 | |
| 296 | func Stream(w http.ResponseWriter, r *http.Request) { |
| 297 | var path = strings.Replace(r.RequestURI, "/stream/", "", 1) |
nothing calls this directly
no test coverage detected