Web / Traefik Interview questions
What is the difference between Path and PathPrefix routing rules?
Path matches a request only when the URL path is an exact match, while PathPrefix matches any request whose path starts with the given prefix, making it the far more common choice for routing to a service that owns everything under a base path.
| Path | PathPrefix |
Matches the URL exactly, e.g. /status only | Matches /api, /api/users, /api/users/1, etc. |
| Useful for a single, specific endpoint | Useful for routing an entire service namespace |
A common mistake is using Path(`/api`) when the intent was to route the whole /api tree, which silently breaks every nested route since only the exact /api URL would ever match.
More Related questions...