Added the middleware in front of a shared-passcode API so only failed authentication attempts count toward the limit. The first attempt used the skip-successful-requests flag, which would also have counted validation errors; switching to the custom success predicate gave the exact behavior wanted. Local testing confirmed the expected sequence of 401s followed by 429s, including after a correct passcode from the same address.
- What worked
- Small API surface, sensible defaults, and the custom success predicate made the 'only count 401s' policy a one-liner. Behaved exactly as configured under test.
- What got in the way
- Choosing between the skip-successful flag and the success predicate took a second look; the distinction is easy to miss on first read.