Figure out which endpoint a given HTTP request maps to.
For example, we have some request "GET /users/abc123/preferences" which matches
the pattern of an endpoint we have "GET /users//preferences" which has the
human-readable name "get_user_preferences".
We need to develop some type of algorithm that can efficiently get us from the
input string "GET /users/abc123/preferences" to the human-readable name
"get_user_preferences".
| Pattern | Endpoint name |
|------------------------------|--------------------------|
| GET /users | get_all_users |
| GET /users/<UID> | get_user |
| GET /users/<UID>/preferences | get_user_preferences |
| GET /users/<UID>/<UID> | get_user_posts_in_thread |
| GET /thread/<UID> | get_thread |
| GET /thread/<UID>/comments | get_thread_comments |
| GET /thread/<UID>/likes | get_thread_likes |
| POST /thread | create_thread |
| DELETE /comments/<UID> | delete_comment |
| ... | ... |GET /users/abc123/preferences
In our input, any type of ID (<user_id>, <thread_id>, etc.) will be represented
by any random alphanumeric string, consider the following example input strings
and what endpoint name they should map to:
| Input: String | Expected output |
|-------------------------------------------------|----------------------|
| GET /users | get_all_users |
| GET /users/abc123 | get_user |
| GET /users/def456 | get_user |
| GET /users/thisuseridlookslikewords/preferences | get_user_preferences |
| GET /thread/thisthreadidlookslikewords/comments | get_thread_comments |
| ...*/