Split voting into clean read/write endpoints
Replaces the GET-mutates-state interactions route with a proper split:
- GET /entry/{pid}/votes reads the tally (public, read-only)
- POST /entry/{pid}/vote casts/toggles the vote (auth, mode in body)
Shared voteTally/writeTally helpers back both handlers. Invalid mode now
returns 400. Frontend updated to read via GET and vote via POST.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -28,7 +28,7 @@ func main() {
|
||||
|
||||
// --- Entries ---
|
||||
r.Get("/entry/feed/{page}", handleFeed)
|
||||
r.Get("/entry/{pid}/interactions/{mode}", handleInteractions)
|
||||
r.Get("/entry/{pid}/votes", handleVotes)
|
||||
|
||||
// --- User (öffentlich) ---
|
||||
r.Get("/u/{username}", handleUserPage)
|
||||
@@ -37,6 +37,7 @@ func main() {
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Use(requireAuth)
|
||||
r.Post("/entry/create", handleCreateEntry)
|
||||
r.Post("/entry/{pid}/vote", handleVote)
|
||||
r.Get("/user/info", handleUserInfo)
|
||||
r.Post("/user/delete", handleUserDelete)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user