Path Patterns

Master path patterns in moclojer - wildcards, regex, precedence, and complex routing. Learn to create flexible URL patterns for sophisticated API mocking.

Learn advanced path pattern techniques to create flexible and powerful URL routing in moclojer.

πŸ“‹ Pattern Types

1. Static Paths

- endpoint:
    path: /users
- endpoint:
    path: /api/v1/products

2. Path Parameters

# Single parameter
- endpoint:
    path: /users/:id

# Multiple parameters
- endpoint:
    path: /posts/:postId/comments/:commentId

# Typed parameters
- endpoint:
    path: /users/:id|int
    path: /posts/:slug|string

3. Wildcards

🎯 Route Precedence

moclojer matches routes in this order:

  1. Exact matches first

  2. Path parameters second

  3. Wildcards last

βœ… Best Practices

Do βœ…:

  • Use specific patterns before generic ones

  • Type your parameters (:id|int)

  • Document complex patterns

Don't ❌:

  • Don't rely on order for precedence

  • Avoid overlapping patterns

πŸ“š See Also

Last updated

Was this helpful?