Fix: sse changes

This commit is contained in:
Grail Finder
2025-05-10 09:01:51 +03:00
parent 2f4891473b
commit 416cc63ec0
6 changed files with 44 additions and 31 deletions

11
main.go
View File

@ -11,10 +11,11 @@ import (
func ListenToRequests(port string) error {
mux := http.NewServeMux()
server := &http.Server{
Handler: handlers.LogRequests(handlers.GetSession(mux)),
Addr: port,
ReadTimeout: time.Second * 5,
WriteTimeout: time.Second * 5,
Handler: handlers.LogRequests(handlers.GetSession(mux)),
Addr: port,
ReadTimeout: time.Second * 5,
// WriteTimeout: time.Second * 5,
WriteTimeout: 0, // sse streaming
}
fs := http.FileServer(http.Dir("assets/"))
mux.Handle("GET /assets/", http.StripPrefix("/assets/", fs))
@ -34,6 +35,8 @@ func ListenToRequests(port string) error {
mux.HandleFunc("GET /room/hideform", handlers.HandleHideCreateForm)
mux.HandleFunc("GET /word/show-color", handlers.HandleShowColor)
mux.HandleFunc("POST /check/name", handlers.HandleNameCheck)
// sse
mux.Handle("GET /sub/sse", handlers.Notifier)
slog.Info("Listening", "addr", port)
return server.ListenAndServe()
}