forked from shimberger/gohls
-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.go
27 lines (23 loc) · 987 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package main
import (
"flag"
"net/http"
"path"
)
func main() {
flag.Parse()
uiDirectory := path.Join(".", "ui")
indexHtml := path.Join(uiDirectory, "index.html")
contentDir := path.Join(".", "videos")
if flag.NArg() > 0 {
contentDir = flag.Arg(0)
}
http.Handle("/", http.RedirectHandler("/ui/",302))
http.Handle("/ui/assets/", http.StripPrefix("/ui/", http.FileServer(http.Dir(uiDirectory))))
http.Handle("/ui/", NewDebugHandlerWrapper(http.StripPrefix("/ui/", NewSingleFileServer(indexHtml))))
http.Handle("/list/", NewDebugHandlerWrapper(http.StripPrefix("/list/", NewListHandler(contentDir))))
http.Handle("/frame/", NewDebugHandlerWrapper(http.StripPrefix("/frame/", NewFrameHandler(contentDir))))
http.Handle("/playlist/", NewDebugHandlerWrapper(http.StripPrefix("/playlist/", NewPlaylistHandler(contentDir))))
http.Handle("/segments/", NewDebugHandlerWrapper(http.StripPrefix("/segments/", NewStreamHandler(contentDir))))
http.ListenAndServe(":8080", nil)
}