Here's an example node routing config:
var requestHandlers = require("./requestHandlers");
var handle = {}
handle["/"] = requestHandlers.start;
handle["/start"] = requestHandlers.start;
handle["/upload"] = requestHandlers.upload;
Its a mapping of URLs and request handlers. Simple, utilitarian, but what about the powerful format string syntax of MVC 3?
routes.MapRoute(
"MediaRoute", // Route name
"{mediaTopic}/{mediaType}/{id}", // URL with parameters
new { controller = "Media", action = "DisplayMediaItemById" },
new { mediaType = "Article|Insight|Infographic" }
It allows for regexes in the {} variable names like mediaType, used in the route and defining its regex.
I'm sure adding regexes to node routing in some way will solve the disconnect. Maybe if someone made the MVC->开发者_开发知识库node transition they will have an answer. Have I missed any great node routing features?
If you just want to turn regexp on your route then look expressjs guide for the answer.
精彩评论