commit 08f1b0d91bac9612df7ca8dc3a03acd12d76f636
parent c8e23aaf9876b095d75928379b65c5dfdefbef5a
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Sun, 11 Jun 2023 22:54:35 -0700
cleanup
Diffstat:
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/pkg/web/handlers/handlers.go b/pkg/web/handlers/handlers.go
@@ -5023,14 +5023,18 @@ func ChessGameHandler(c echo.Context) error {
//}
//isYourTurn := isYourTurnFn()
+ send := func(s string) {
+ _, _ = c.Response().Write([]byte(s))
+ }
+
// If you are not a spectator, and it's your turn to play, we just render the form directly.
if g.Game.Outcome() != chess.NoOutcome {
c.Response().Header().Set(echo.HeaderContentType, echo.MIMETextHTMLCharsetUTF8)
c.Response().WriteHeader(http.StatusOK)
- _, _ = c.Response().Write([]byte(cssReset))
- _, _ = c.Response().Write([]byte(`<style>html, body { background-color: #222; }</style>`))
- card1 := g.DrawPlayerCard(key, isFlipped, false)
- _, _ = c.Response().Write([]byte(fmt.Sprintf(`<div id="div_0">%s</div>`, card1)))
+ send(cssReset)
+ send(`<style>html, body { background-color: #222; }</style>`)
+ card := g.DrawPlayerCard(key, isFlipped, false)
+ send(card)
return nil
}
@@ -5041,10 +5045,6 @@ func ChessGameHandler(c echo.Context) error {
}
defer usersStreamsManager.Remove(authUser.ID)
- send := func(s string) {
- _, _ = c.Response().Write([]byte(s))
- }
-
c.Response().Header().Set(echo.HeaderContentType, echo.MIMETextHTMLCharsetUTF8)
c.Response().WriteHeader(http.StatusOK)
c.Response().Header().Set("Transfer-Encoding", "chunked")