Draft: big refactor

This commit is contained in:
2025-09-16 16:03:27 +08:00
parent f527230f1e
commit 08c23bb29b
33 changed files with 339 additions and 155 deletions

32
workflows/wordleServer.go Normal file
View File

@@ -0,0 +1,32 @@
package workflows
import (
"context"
"log"
"net/http"
"gitea.konchin.com/ytshih/inp2025/game/implements"
"gitea.konchin.com/ytshih/inp2025/game/server/middlewares"
"gitea.konchin.com/ytshih/inp2025/game/server/wordle"
"github.com/spf13/viper"
"github.com/uptrace/bunrouter"
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
)
func WordleServer(ctx context.Context) {
handlers := wordle.NewHandlers()
middlewareHandlers := middlewares.NewHandlers(
implements.NewBunDatabase(nil))
router := bunrouter.New()
apiGroup := router.NewGroup("/api").
Use(middlewareHandlers.ErrorHandler)
apiGroup.GET("/state",
handlers.WSGetState)
apiGroup.POST("/guess",
handlers.WSPostGuess)
log.Println(http.ListenAndServe(":"+viper.GetString("port"),
otelhttp.NewHandler(router, "")))
}