[server] remove /admin prefix#5
Conversation
📝 WalkthroughWalkthroughThe PR refactors the user management API by relocating endpoints from Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
🤖 Pull request artifacts
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
internal/server/users/dto.go (1)
31-34: Use a method-agnostic response name and fix the stale comment.
GetResponseis now the shared payload for both list and update flows, so the name reads narrower than the actual contract, and Line 60 still refers to the removedUserResponsetype. A neutral name likeResponseorUserResponsewould make this easier to follow.Also applies to: 60-61
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@internal/server/users/dto.go` around lines 31 - 34, Rename the GetResponse struct to a neutral name (e.g., UserResponse or Response) and update its doc comment to reflect that it is the shared payload for list and update flows (remove "Get" phrasing and stale reference to UserResponse). Update any remaining references/comments that mention the removed UserResponse type (notably the text around lines 60-61) to the new name so the comment and typedef are consistent (search for GetResponse and the old UserResponse text and replace accordingly).requests.http (1)
81-108: Avoid fixed user IDs in the runnable examples.Line 82, Line 92, and Line 102 depend on IDs
2,3, and4, which are not stable across environments. These examples will 404 on a clean database unless the fixture order happens to match. Prefer captured IDs or explicit placeholders sorequests.httpstays replayable.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@requests.http` around lines 81 - 108, The examples in requests.http use hard-coded user IDs (PATCH {{baseURL}}/users/2, /users/3, /users/4) which will 404 in fresh environments; replace those fixed IDs with reusable placeholders or captured variables (for example {{pendingUserId}}, {{blockedUserId}}, {{adminUserId}}) or add preceding create-user requests that extract and set the ID into those variables so the PATCH examples are replayable; update the three PATCH request lines and any JSON comments to reference the new placeholders.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@internal/server/users/handler.go`:
- Around line 35-46: The route change in Handler.Register replaced the public
path (/admin/users → /users) breaking existing clients; restore compatibility by
also registering the legacy path (or versioned path) alongside the new one:
update Register to create an additional route group that uses the same
middleware chain (h.errorsHandler, jwtauth.WithRole(users.RoleAdmin)) and binds
the same handlers (h.handleList and validation.DecorateWithBodyEx(h.Validator,
h.handleUpdate)) to the legacy endpoints (e.g., "/admin/users" or
"/api/v1/admin/users") so both old and new paths resolve to the same handler
functions.
---
Nitpick comments:
In `@internal/server/users/dto.go`:
- Around line 31-34: Rename the GetResponse struct to a neutral name (e.g.,
UserResponse or Response) and update its doc comment to reflect that it is the
shared payload for list and update flows (remove "Get" phrasing and stale
reference to UserResponse). Update any remaining references/comments that
mention the removed UserResponse type (notably the text around lines 60-61) to
the new name so the comment and typedef are consistent (search for GetResponse
and the old UserResponse text and replace accordingly).
In `@requests.http`:
- Around line 81-108: The examples in requests.http use hard-coded user IDs
(PATCH {{baseURL}}/users/2, /users/3, /users/4) which will 404 in fresh
environments; replace those fixed IDs with reusable placeholders or captured
variables (for example {{pendingUserId}}, {{blockedUserId}}, {{adminUserId}}) or
add preceding create-user requests that extract and set the ID into those
variables so the PATCH examples are replayable; update the three PATCH request
lines and any JSON comments to reference the new placeholders.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 9b1654e9-5f99-46d4-9946-814f84229a97
📒 Files selected for processing (5)
internal/server/docs/docs.gointernal/server/module.gointernal/server/users/dto.gointernal/server/users/handler.gorequests.http
Summary by CodeRabbit
Bug Fixes
/admin/usersto/userspath for improved API organization.Documentation