Draft: big refactor

This commit is contained in:
2025-09-16 16:03:27 +08:00
parent f527230f1e
commit 85fa3dfe73
47 changed files with 1166 additions and 351 deletions

View File

@@ -0,0 +1,38 @@
package wordle
import (
"io"
"net/http"
"gitea.konchin.com/ytshih/inp2025/game/server/middlewares"
"gitea.konchin.com/ytshih/inp2025/game/utils"
"github.com/uptrace/bunrouter"
"github.com/vmihailenco/msgpack/v5"
)
func (self *Handlers) WSPostGuess(
w http.ResponseWriter,
req bunrouter.Request,
) error {
b, err := io.ReadAll(req.Body)
if err != nil {
return middlewares.HTTPError{
StatusCode: http.StatusBadRequest,
Message: "failed to read body",
OriginError: err,
}
}
var op Operation
if err := msgpack.Unmarshal(b, &op); err != nil {
return middlewares.HTTPError{
StatusCode: http.StatusBadRequest,
Message: "failed to unmarshal msgpack",
OriginError: err,
}
}
self.opCh <- op
return utils.Success(w)
}