Implement: HTTP handlers and routing — dashboard, categories, and review endpoints #17

Open
opened 2026-08-20 15:32:07 +02:00 by gaetan · 0 comments
Owner

Wayfinder map: #1
Dependencies: #13 (project scaffolding), #16 (SM-2 review engine), #15 (database layer)

Description

Build the HTTP layer: routing, handlers wired to database and review packages, JSON responses. No templates yet — just routing and handler logic.

Tasks

  • Create web/handlers/ package
  • Use net/http ServeMux for routing
  • Routes:
    • GET / — dashboard (JSON: stats, due count, category summary)
    • GET /categories — list categories with card counts
    • GET /review — get next review card (JSON: card data + session info)
    • POST /review/rate — submit rating (JSON body: card_id, rating)
  • Handlers wired to:
    • Database package for card/progress queries
    • Review package for SM-2 scheduling
  • /review/rate response:
    • Returns next card JSON or session complete message
    • Updates progress in database
  • Error handling: invalid input, missing card, DB errors
  • No templates yet — just routing and handler logic

Acceptance criteria

  • All 4 routes respond correctly
  • /review/rate returns next card or session complete
  • Handlers properly integrate with database and review packages
  • Error cases handled gracefully
  • HTTP server can be started from main.go
**Wayfinder map:** #1 **Dependencies:** #13 (project scaffolding), #16 (SM-2 review engine), #15 (database layer) ## Description Build the HTTP layer: routing, handlers wired to database and review packages, JSON responses. No templates yet — just routing and handler logic. ## Tasks - [ ] Create `web/handlers/` package - [ ] Use `net/http` ServeMux for routing - [ ] Routes: - `GET /` — dashboard (JSON: stats, due count, category summary) - `GET /categories` — list categories with card counts - `GET /review` — get next review card (JSON: card data + session info) - `POST /review/rate` — submit rating (JSON body: card_id, rating) - [ ] Handlers wired to: - Database package for card/progress queries - Review package for SM-2 scheduling - [ ] `/review/rate` response: - Returns next card JSON or session complete message - Updates progress in database - [ ] Error handling: invalid input, missing card, DB errors - [ ] No templates yet — just routing and handler logic ## Acceptance criteria - All 4 routes respond correctly - `/review/rate` returns next card or session complete - Handlers properly integrate with database and review packages - Error cases handled gracefully - HTTP server can be started from main.go
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
gaetan/knowledgify#17
No description provided.