Commit 88e06c7
committed
refactor: improve middleware and error handling
Enhance authentication middleware with precise endpoint detection and
structured error types for better debugging and error handling.
Middleware improvements:
- Segment-based path matching instead of string contains
- Match "sessions" only as last or second-to-last path segment
- Prevents false positives on URLs like /users/sessions_count
Error handling improvements:
- AuthError enum with specific variants per failure mode
- is_retryable() method for intelligent retry logic
- Captures HTTP status codes and response bodies for debugging
- Backwards compatible with anyhow::Result
Assisted-by: Claude 4 Sonnet
Signed-off-by: Sergio Correia <[email protected]>1 parent a13e173 commit 88e06c7
1 file changed
+33
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
319 | 319 | | |
320 | 320 | | |
321 | 321 | | |
322 | | - | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
323 | 338 | | |
324 | 339 | | |
325 | 340 | | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
330 | 349 | | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
331 | 357 | | |
332 | 358 | | |
333 | 359 | | |
| |||
1282 | 1308 | | |
1283 | 1309 | | |
1284 | 1310 | | |
1285 | | - | |
1286 | | - | |
| 1311 | + | |
| 1312 | + | |
1287 | 1313 | | |
1288 | 1314 | | |
1289 | 1315 | | |
| |||
0 commit comments