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

Function Threadfin

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

Source from the content-addressed store, hash-verified

401}
402
403func Threadfin(w http.ResponseWriter, r *http.Request) {
404
405 var requestType, groupTitle, file, content, contentType string
406 var err error
407 var path = strings.TrimPrefix(r.URL.Path, "/")
408 var groups = []string{}
409
410 systemMutex.Lock()
411 if Settings.HttpThreadfinDomain != "" {
412 setGlobalDomain(getBaseUrl(Settings.HttpThreadfinDomain, Settings.Port))
413 } else {
414 setGlobalDomain(r.Host)
415 }
416 systemMutex.Unlock()
417
418 if strings.Contains(path, "xmltv/") {
419
420 requestType = "xml"
421
422 err = urlAuth(r, requestType)
423 if err != nil {
424 ShowError(err, 000)
425 httpStatusError(w, r, 403)
426 return
427 }
428
429 systemMutex.Lock()
430 file = System.Folder.Data + getFilenameFromPath(path)
431 systemMutex.Unlock()
432
433 content, err = readStringFromFile(file)
434 if err != nil {
435 httpStatusError(w, r, 404)
436 return
437 }
438
439 }
440
441 if strings.Contains(path, "m3u/") {
442
443 requestType = "m3u"
444
445 err = urlAuth(r, requestType)
446 if err != nil {
447 ShowError(err, 000)
448 httpStatusError(w, r, 403)
449 return
450 }
451
452 groupTitle = r.URL.Query().Get("group-title")
453
454 systemMutex.Lock()
455 m3uFilePath := System.Folder.Data + "threadfin.m3u"
456 systemMutex.Unlock()
457
458 queries := r.URL.Query()
459
460 if len(queries) == 0 {

Callers

nothing calls this directly

Calls 8

setGlobalDomainFunction · 0.85
getBaseUrlFunction · 0.85
urlAuthFunction · 0.85
ShowErrorFunction · 0.85
httpStatusErrorFunction · 0.85
readStringFromFileFunction · 0.85
buildM3UFunction · 0.85
getFilenameFromPathFunction · 0.70

Tested by

no test coverage detected