补全:路由表
不用 if 链,用一张表。补全 dispatch(routes, method, path):routes 是 {(方法, 路径): 处理函数};找到就调它交回结果;路径存在但方法不对交回 (405, "方法不对");都没有交回 (404, "没有")。
不用 if 链,用一张表。补全 dispatch(routes, method, path):routes 是 {(方法, 路径): 处理函数};找到就调它交回结果;路径存在但方法不对交回 (405, "方法不对");都没有交回 (404, "没有")。
全部评论