Implement HTTP Route Matching for a Web Framework
Implement two functions, `registerHandler(pattern)` and `getHandler(path)`, that form the core routing logic of a web framework. `registerHandler` adds URL patterns (which may include `{parameter}` placeholders) to the router, while `getHandler` matches an incoming request path against registered patterns and returns the matching pattern or null if none exists.
Asked at:
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Early May, 2026
Junior
You are tasked to implement the core HTTP routing logic of a new web framework similar to spring boot There should be 2 func, registerHandler and getHandler registerHandler(pattern:string) called when dev adds handler. add new URL pattern that can contain {parameters} getHandler(path:string) called when real URL is requested from sevice. Return correct pattern when string of null if none matches Ex: regigsterHandler("/home") getHandler("/home") returns /home getHandler("/users") returns null
Hello Interview Premium
Your account is free and you can post anonymously if you choose.