Добавление камеры на сервер

This commit is contained in:
Tot Maxim
2026-05-09 18:20:00 +03:00
parent 549b0c5e63
commit e36823d3ba
6 changed files with 420 additions and 37 deletions

View File

@@ -16,6 +16,7 @@ import (
)
// ===== EMBED WEB =====
//
//go:embed web/*
var webFiles embed.FS
@@ -75,6 +76,12 @@ func (a *API) HandleHistory(w http.ResponseWriter, r *http.Request) {
})
}
func (a *API) HandleStream(w http.ResponseWriter, r *http.Request) {
writeJSON(w, map[string]string{
"cam": "http://192.168.77.1:1984/stream.html?src=cam",
})
}
// ===== PIPE READER =====
func startPipeReader(ctx context.Context, buf *adapter.RingBuffer, path string) {
@@ -137,7 +144,6 @@ func main() {
// ===== API =====
http.Handle("/api/", http.StripPrefix("/api", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case "/latest":
cors(api.HandleLatest)(w, r)
@@ -145,6 +151,8 @@ func main() {
cors(api.HandleHistory)(w, r)
case "/health":
cors(api.HandleHealth)(w, r)
case "/stream":
cors(api.HandleStream)(w, r)
default:
http.Error(w, "not found", 404)
}