mirror of
https://github.com/AlexxIT/go2rtc.git
synced 2025-09-27 04:36:12 +08:00
26 lines
433 B
Go
26 lines
433 B
Go
package api
|
|
|
|
import (
|
|
"github.com/AlexxIT/go2rtc/www"
|
|
"net/http"
|
|
)
|
|
|
|
func initStatic(staticDir string) {
|
|
var root http.FileSystem
|
|
if staticDir != "" {
|
|
root = http.Dir(staticDir)
|
|
} else {
|
|
root = http.FS(www.Static)
|
|
}
|
|
|
|
fileServer := http.FileServer(root)
|
|
|
|
HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
|
if basePath != "" {
|
|
r.URL.Path = r.URL.Path[len(basePath):]
|
|
}
|
|
|
|
fileServer.ServeHTTP(w, r)
|
|
})
|
|
}
|