package handlers import ( "context" "net/http" "git.haelnorr.com/h/golib/hws" "github.com/pkg/errors" "github.com/uptrace/bun" "git.haelnorr.com/h/oslstats/internal/db" "git.haelnorr.com/h/oslstats/internal/view/leaguesview" ) func LeaguesList( s *hws.Server, conn *db.DB, ) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { var leagues []*db.League if ok := conn.WithReadTx(s, w, r, func(ctx context.Context, tx bun.Tx) (bool, error) { var err error leagues, err = db.GetLeagues(ctx, tx) if err != nil { return false, errors.Wrap(err, "db.GetLeagues") } return true, nil }); !ok { return } renderSafely(leaguesview.ListPage(leagues), s, r, w) }) }