InterviewSolution
| 1. |
What Is Pattern Matched Routes? |
|
Answer» You can also use REGEX to restrict URL parameter matching. LET's say you need the id to be 5 digits long number. You can use the following ROUTE definition: var koa = require('koa'); Note that this will only match the requests that have a 5 digit long id. You can use more complex regexes to match/validate your routes. If NONE of your routes match the request, you'll get a Not found message as response. You can also use regex to restrict URL parameter matching. Let's say you need the id to be 5 digits long number. You can use the following route definition: var koa = require('koa'); Note that this will only match the requests that have a 5 digit long id. You can use more complex regexes to match/validate your routes. If none of your routes match the request, you'll get a Not found message as response. |
|