MCPcopy Index your code
hub / github.com/Threadfin/Threadfin / Index

Function Index

src/webserver.go:243–294  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

241}
242
243func 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
296func Stream(w http.ResponseWriter, r *http.Request) {
297 var path = strings.Replace(r.RequestURI, "/stream/", "", 1)

Callers

nothing calls this directly

Calls 9

setGlobalDomainFunction · 0.85
getBaseUrlFunction · 0.85
getDiscoverFunction · 0.85
getLineupStatusFunction · 0.85
basicAuthFunction · 0.85
ShowErrorFunction · 0.85
httpStatusErrorFunction · 0.85
getLineupFunction · 0.85
getCapabilityFunction · 0.85

Tested by

no test coverage detected