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

Function StartWebserver

src/webserver.go:197–241  ·  view source on GitHub ↗

StartWebserver : Startet den Webserver

()

Source from the content-addressed store, hash-verified

195
196// StartWebserver : Startet den Webserver
197func StartWebserver() (err error) {
198 systemMutex.Lock()
199 port := Settings.Port
200 ipAddress := System.IPAddress
201 if Settings.BindIpAddress != "" {
202 ipAddress = Settings.BindIpAddress
203 }
204 systemMutex.Unlock()
205
206 http.HandleFunc("/", Index)
207 http.HandleFunc("/stream/", Stream)
208 http.HandleFunc("/xmltv/", Threadfin)
209 http.HandleFunc("/m3u/", Threadfin)
210 http.HandleFunc("/data/", WS)
211 http.HandleFunc("/web/", Web)
212 http.HandleFunc("/download/", Download)
213 http.HandleFunc("/api/", API)
214 http.HandleFunc("/images/", Images)
215 http.HandleFunc("/data_images/", DataImages)
216 http.HandleFunc("/ppv/enable", enablePPV)
217 http.HandleFunc("/ppv/disable", disablePPV)
218 http.HandleFunc("/auto/", Auto)
219
220 systemMutex.Lock()
221 ips := len(System.IPAddressesV4) + len(System.IPAddressesV6) - 1
222 switch ips {
223 case 0:
224 showHighlight(fmt.Sprintf("Web Interface:%s://%s:%s/web/", System.ServerProtocol.WEB, ipAddress, Settings.Port))
225 case 1:
226 showHighlight(fmt.Sprintf("Web Interface:%s://%s:%s/web/ | Threadfin is also available via the other %d IP.", System.ServerProtocol.WEB, ipAddress, Settings.Port, ips))
227 default:
228 showHighlight(fmt.Sprintf("Web Interface:%s://%s:%s/web/ | Threadfin is also available via the other %d IP's.", System.ServerProtocol.WEB, ipAddress, Settings.Port, len(System.IPAddressesV4)+len(System.IPAddressesV6)-1))
229 }
230 systemMutex.Unlock()
231
232 go func() {
233 if err = http.ListenAndServe(ipAddress+":"+port, nil); err != nil {
234 ShowError(err, 1001)
235 }
236 }()
237
238 time.Sleep(100 * time.Millisecond)
239
240 return
241}
242
243func Index(w http.ResponseWriter, r *http.Request) {
244 var err error

Callers 1

mainFunction · 0.92

Calls 2

showHighlightFunction · 0.85
ShowErrorFunction · 0.85

Tested by

no test coverage detected