diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-03-08 20:40:31 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-03-08 20:40:31 +0000 |
| commit | 417034be7f745062901a940d1a021f6d85be496e (patch) | |
| tree | 666956207b58c915090f6641891304156cf93670 /internal/api/validate.go | |
| parent | 181a37698410b68e00a885593b6f2b7acf21f4b4 (diff) | |
api: SetAPIToken, SetNotifier, questionStore, per-IP rate limiter
- Extract questionStore interface for testability of handleAnswerQuestion
- Add SetAPIToken/SetNotifier methods for post-construction wiring
- Extract processResult() from forwardResults() for direct testability
- Add ipRateLimiter with token-bucket per IP; applied to /elaborate and /validate
- Fix tests for running-task deletion and retry-limit that relied on
invalid state transitions in setup
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/api/validate.go')
| -rw-r--r-- | internal/api/validate.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/internal/api/validate.go b/internal/api/validate.go index 4b691a9..0fcdb47 100644 --- a/internal/api/validate.go +++ b/internal/api/validate.go @@ -52,6 +52,11 @@ func (s *Server) validateBinaryPath() string { } func (s *Server) handleValidateTask(w http.ResponseWriter, r *http.Request) { + if s.elaborateLimiter != nil && !s.elaborateLimiter.allow(realIP(r)) { + writeJSON(w, http.StatusTooManyRequests, map[string]string{"error": "rate limit exceeded"}) + return + } + var input struct { Name string `json:"name"` Claude struct { |
