spark-server/.cursor/rules/http-mvc.mdc
zhr ae9a71034d feat: implement Spark IM V3 modular monolith
Add HTTP /v1 MVC, TCP send path, groups with server-side member-avatar collage, object-storage upload, and friends/favorites around the architecture-v3 layout.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-17 19:52:11 +08:00

17 lines
1.0 KiB
Plaintext

---
description: HTTP MVC, validator i18n keys, RealIP and language on context, REST groups.
globs: internal/transport/http/**/*.go,internal/pkg/validate/**/*.go,internal/pkg/reqctx/**/*.go,internal/pkg/i18n/**/*.go
alwaysApply: false
---
# HTTP MVC
Source: `.cursor/skills/spark-im-v3/http.md` and `i18n.md`.
- Handlers only bind and call Application services. Login and other business live in `internal/module/*`, never in Gin handlers.
- Bind JSON with `respond.BindJSON` + `validate` / `label` / `errmsg` **i18n keys**. Client `msg` is localized (`zh-CN` / `en` / `zh-TW`).
- Put `RealIP` and `Language` on `reqctx.RequestContext`. HTTP: `X-Language` or `Accept-Language`. TCP: AUTH `language`. Rate limit uses `reqctx.RealIP(ctx)`. Errors/notices use `reqctx.Lang(ctx)`.
- Routes are REST under `/v1/{resource}` and grouped by business in `router.go`.
- Do not import package `httpx` from `handler/*` (cycle). Use `internal/transport/http/respond`.
- Do not hardcode error or notification strings; add catalog entries in `internal/pkg/i18n`.