DUP-GO-9: requireGET and requirePOST differ only in method string #52

Closed
opened 2026-05-27 16:57:58 +02:00 by dries · 0 comments
Owner

Summary

requireGET (lines 323–332) and requirePOST (lines 334–343) in internal/server/server.go are 9-line functions that are structurally identical, differing only in the HTTP method string.

Fix

Extract a requireMethod(method string) func(http.Handler) http.Handler factory. requireGET and requirePOST become one-liner wrappers.

Effort

Trivial. Low value — current code is clear and readable, but adds friction when adding a new method.

## Summary `requireGET` (lines 323–332) and `requirePOST` (lines 334–343) in `internal/server/server.go` are 9-line functions that are structurally identical, differing only in the HTTP method string. ## Fix Extract a `requireMethod(method string) func(http.Handler) http.Handler` factory. `requireGET` and `requirePOST` become one-liner wrappers. ## Effort Trivial. Low value — current code is clear and readable, but adds friction when adding a new method.
dries closed this issue 2026-07-11 11:23:18 +02:00
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
dries/ocman#52
No description provided.