feat: add admin routes
This commit is contained in:
@@ -67,6 +67,8 @@ func (h *Handler) Routes(user, pass string) http.Handler {
|
||||
r.Get("/tournaments", h.tournamentsAdmin)
|
||||
r.Post("/tournaments/add", h.tournamentAdd)
|
||||
r.Post("/tournaments/delete", h.tournamentDelete)
|
||||
// APIِ JSON برای پنلِ Next.js (پشتِ همان Basic Auth).
|
||||
r.Mount("/api", h.APIRoutes())
|
||||
return r
|
||||
}
|
||||
|
||||
@@ -661,7 +663,12 @@ func newUUID() string {
|
||||
}
|
||||
|
||||
func (h *Handler) rows(ctx context.Context, query string, cols ...string) []map[string]any {
|
||||
rs, err := h.db.QueryContext(ctx, query)
|
||||
return h.rowsArgs(ctx, query, nil, cols...)
|
||||
}
|
||||
|
||||
// rowsArgs مثلِ rows اما با پارامترهای کوئری.
|
||||
func (h *Handler) rowsArgs(ctx context.Context, query string, args []any, cols ...string) []map[string]any {
|
||||
rs, err := h.db.QueryContext(ctx, query, args...)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user