http3
This commit is contained in:
8
main.go
8
main.go
@@ -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"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user