64 lines
1.8 KiB
Go
64 lines
1.8 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
"os"
|
|
|
|
"git.insit.tech/psa/rtsp_reader-writer/reader/internal/config"
|
|
logger "git.insit.tech/psa/rtsp_reader-writer/reader/internal/log"
|
|
"git.insit.tech/psa/rtsp_reader-writer/reader/internal/metrics"
|
|
"git.insit.tech/psa/rtsp_reader-writer/reader/internal/web/handlers"
|
|
"git.insit.tech/psa/rtsp_reader-writer/reader/internal/web/middlewares"
|
|
)
|
|
|
|
func main() {
|
|
go metrics.Metrics()
|
|
logger.StartMainLogger(config.Local, "reader")
|
|
|
|
// Check if the data folder in the directory.
|
|
homeDir, err := os.UserHomeDir()
|
|
if err != nil {
|
|
}
|
|
config.DirData = fmt.Sprintf("%s/%s/vod", homeDir, config.Local)
|
|
//
|
|
//err = unpacker.CreateVideo()
|
|
//if err != nil {
|
|
// logger.Log.Error("failed to create flow", zap.Error(err))
|
|
//}
|
|
|
|
config.Storage.Users = make(map[string]config.User)
|
|
|
|
mux := http.NewServeMux()
|
|
|
|
// Public routes.
|
|
mux.HandleFunc("POST /register", handlers.Register)
|
|
mux.HandleFunc("POST /login", handlers.Login)
|
|
|
|
// Authorized routes.
|
|
//authorizedGroup := http.NewServeMux()
|
|
//authorizedGroup.HandleFunc("GET /profile", userHandlerQUIC.Profile)
|
|
|
|
// API Flussonic Media Server adapted handlers.
|
|
//mux.HandleFunc("GET /vods/:id/:res/:file", handlersQUIC.SingleVodsHandler)
|
|
//mux.HandleFunc("DELETE /vods/:id/:res/:file", handlersQUIC.DelSingleVodsHandler)
|
|
//mux.HandleFunc("GET /vods/:id/files", handlersQUIC.ListFilesVodsHandler)
|
|
//mux.HandleFunc("DELETE /vods/:id", handlersQUIC.DelVodsHandler)
|
|
//mux.HandleFunc("GET /vods/:id", handlersQUIC.ConfigVodsHandler)
|
|
mux.Handle("GET /vods", middlewares.AuthMiddleware(handlers.ListVodsHandler()))
|
|
|
|
http.ListenAndServe(":8080", mux)
|
|
|
|
// HTTP/1.1 & HTTP/2
|
|
go func() {
|
|
//http.ListenAndServeTLS(":8080", certFile, keyFile, mux)
|
|
|
|
}()
|
|
|
|
//server := &http3.Server{
|
|
// Addr: ":8080",
|
|
// Handler: mux,
|
|
// TLSConfig: quic.GetTLSConfig(),
|
|
//}
|
|
}
|