Feat: demo
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package wordle
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
@@ -8,12 +9,11 @@ import (
|
||||
"gitea.konchin.com/ytshih/inp2025/middlewares"
|
||||
"gitea.konchin.com/ytshih/inp2025/utils"
|
||||
"github.com/uptrace/bunrouter"
|
||||
"github.com/vmihailenco/msgpack/v5"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type PostGuessInput struct {
|
||||
Guess string `msgpack:"guess"`
|
||||
Guess string `json:"guess"`
|
||||
}
|
||||
|
||||
func (self *Handlers) PostGuess(
|
||||
@@ -31,7 +31,7 @@ func (self *Handlers) PostGuess(
|
||||
}
|
||||
|
||||
var input PostGuessInput
|
||||
if err := msgpack.Unmarshal(b, &input); err != nil {
|
||||
if err := json.Unmarshal(b, &input); err != nil {
|
||||
return middlewares.HTTPError{
|
||||
StatusCode: http.StatusBadRequest,
|
||||
Message: "failed to unmarshal from msgpack",
|
||||
@@ -39,9 +39,6 @@ func (self *Handlers) PostGuess(
|
||||
}
|
||||
}
|
||||
|
||||
zap.L().Info("input",
|
||||
zap.String("input", fmt.Sprintf("%+v", input)))
|
||||
|
||||
username, _, ok := req.BasicAuth()
|
||||
if !ok {
|
||||
return middlewares.HTTPError{
|
||||
@@ -50,6 +47,10 @@ func (self *Handlers) PostGuess(
|
||||
}
|
||||
}
|
||||
|
||||
zap.L().Info("input",
|
||||
zap.String("input", fmt.Sprintf("%+v", input)),
|
||||
zap.String("username", username))
|
||||
|
||||
self.opCh <- &OperationGuess{
|
||||
Username: username,
|
||||
Guess: input.Guess,
|
||||
|
||||
Reference in New Issue
Block a user