Ember.js http模拟命名约定

Ember.js http模拟命名约定,ember.js,ember-data,Ember.js,Ember Data,我使用Ember CLI和以下命令设置了http模拟路由: ember g http-mock exercise-templates 然后设置文件exerce-templates.js,该文件定义为: module.exports = function(app) { var express = require('express'); var exerciseTemplatesRouter = express.Router(); exerciseTemplatesRou

我使用Ember CLI和以下命令设置了http模拟路由:

 ember g http-mock exercise-templates
然后设置文件exerce-templates.js,该文件定义为:

module.exports = function(app) {
    var express = require('express');
    var exerciseTemplatesRouter = express.Router();
    exerciseTemplatesRouter.get('/', function(req, res) {
        res.send({
            "exercise-templates":[      
                {id: 1, name: 'Military Press', type: 'strength', muscles: [] },
                {id: 2, name: 'Situps', type: 'strength', muscles: [] },
                {id: 3, name: 'Yoga', type: 'class', muscles: [] },
                {id: 4, name: 'Pilattes', type: 'class', muscles: [] }
            ]
        });
    });
    app.use('/api/exercise-templates', exerciseTemplatesRouter);
};
因此,当我将浏览器指向http://localhost:4200/api/exercise-我希望得到上面定义的静态JSON响应的模板。相反,我得到了404。然后,令我惊讶的是,我输入了http://localhost:4200/api/exercise-模板aka,没有“s”,它工作了。嗯?让我想知道发生了什么。。。我的意思是我不是速成大师,但不:

app.use('/api/exercise-templates', exerciseTemplatesRouter);

是否暗示将使用复数命名约定?

好吧,答案是。。。关闭余烬服务并重新启动。不知道为什么它不会让人耳目一新,但很明显,嘲弄并不总是如此?更新时优雅地刷新。无论如何,我对命名约定的期望似乎是命名约定,因此我可以高兴地报告,世界上一切都好起来了。

ember serve启动node express服务器,然后Brocoli监视您的前端文件。因此,是的,每次更改模拟服务器代码时,都需要重新启动ember cli服务器。