33 lines
812 B
Go
33 lines
812 B
Go
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, "")))
|
|
}
|