Draft: big refactor
This commit is contained in:
32
workflows/wordleServer.go
Normal file
32
workflows/wordleServer.go
Normal 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, "")))
|
||||
}
|
||||
Reference in New Issue
Block a user