60 lines
1.8 KiB
Go
60 lines
1.8 KiB
Go
package quic
|
|
|
|
/*
|
|
import (
|
|
"crypto/tls"
|
|
"log"
|
|
"net/http"
|
|
|
|
"git.insit.tech/psa/rtsp_reader-writer/reader/internal/web/quic/handlersQUIC"
|
|
"github.com/quic-go/quic-go/http3"
|
|
)
|
|
|
|
// SetupQuicServer starts QUIC protocol using HTTP/3.
|
|
func SetupQuicServer() {
|
|
mux := http.NewServeMux()
|
|
|
|
// Группа обработчиков, которые доступны неавторизованным пользователям
|
|
mux.HandleFunc("POST /register", handlersQUIC.Register)
|
|
mux.HandleFunc("POST /login", handlersQUIC.Login)
|
|
|
|
// Группа обработчиков, которые требуют авторизации
|
|
//authorizedGroup := app.Group("")
|
|
//authorizedGroup.Use(handlersQUIC.CheckJWT, handlersQUIC.CheckSessionID, handlersQUIC.CreateSessionID)
|
|
//mux.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.HandleFunc("GET /vods", handlersQUIC.ListVodsHandler)
|
|
|
|
server := &http3.Server{
|
|
Addr: ":443",
|
|
Handler: mux,
|
|
}
|
|
|
|
http.ListenAndServe("", mux)
|
|
|
|
if err := server.ListenAndServeTLS("fullchain.pem", "privkey.pem"); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
// GetTLSConfig
|
|
func GetTLSConfig() *tls.Config {
|
|
cert, err := tls.LoadX509KeyPair("fullchain.pem", "privkey.pem")
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
return &tls.Config{
|
|
Certificates: []tls.Certificate{cert},
|
|
NextProtos: []string{"h3", "h2", "http/1.1"},
|
|
MinVersion: tls.VersionTLS13,
|
|
}
|
|
}
|
|
*/
|