This commit is contained in:
“bobbydigitales”
2024-03-25 01:55:49 -07:00
parent c5fccd6048
commit 9140739879
4 changed files with 62 additions and 4 deletions

View File

@@ -50,6 +50,7 @@ import (
"strconv"
"github.com/gorilla/websocket"
"github.com/quic-go/quic-go/http3"
)
var upgrader = websocket.Upgrader{
@@ -121,6 +122,9 @@ func main() {
addr := ":" + strconv.Itoa(port)
log.Printf("Starting server on %s", addr)
// http.Handle("/", http.FileServer(http.Dir(wwwDir)))
// http3.ListenAndServeQUIC("localhost:4242", "/path/to/cert/chain.pem", "/path/to/privkey.pem", nil)
// Set up file server and WebSocket endpoint
fs := http.FileServer(http.Dir(dir))
// loggingHandler := &LoggingHandler{handler: fs}
@@ -130,11 +134,11 @@ func main() {
http.HandleFunc("/ws", handleWebSocket)
// Configure and start the HTTP server
server := &http.Server{
server := &http3.Server{
Addr: addr,
Handler: nil, // nil uses the default ServeMux, which we configured above
}
log.Printf("Server is configured and serving on port %d...", port)
log.Fatal(server.ListenAndServe())
log.Fatal(server.ListenAndServeTLS("./fullchain.pem", "./privkey.pem"))
}