Tag: url routing

flatiron.js路由和模板与工会,董事和板块?

来自express.js,我想给flatiron一个小项目的尝试。 但是,有一些小问题让我无法到达某个地方。 var flatiron = require('flatiron') , session = require('connect').session , ecstatic = require('ecstatic') , path = require('path') , fs = require('fs') , plates = require('plates') , director = require('director') , winston = require('winston') , union = require('union'); var router = new director.http.Router(); var server = union.createServer({ before: [ ecstatic(__dirname + '/public') ] }); router.get('/', […]

HapiJS全局path前缀

我在HapiJS上编写一个API,想知道如何获得一个全局的前缀。 例如,所有的请求都应该做到: https://api.mysite.com/v0/… 所以我想将v0configuration为全局前缀。 文档( 这里 )似乎没有提到它 – 在HapiJS中有这样做的好方法吗?

Hapi嵌套路由

假设我想让REST端点看起来像这样: /projects/ /projects/project_id /projects/project_id/items/ /projects/project_id/items/item_id 每个CRUD都是有道理的。 例如,/项目POST创build一个新项目,GET获取所有项目。 / projects / project_id GET只提取一个项目。 项目是特定项目,所以我把它们放在project_id下,这是一个特定的项目。 有没有办法创build这种嵌套的路线? 现在我有这样的东西: server.route({ method: 'GET', path: '/projects', handler: getAllProjects }); server.route({ method: 'GET', path: '/projects/{project_id}', handler: getOneProject }); server.route({ method: 'GET', path: '/projects/{project_id}/items/{item_id}', handler: getOneItemForProject }); server.route({ method: 'GET', path: '/projects/{project_id}/items', handler: getAllItemsForProject }) 但是我正在寻找一种方法将物品路线embedded到项目路线中,并且有能力进一步传递项目。 任何build议?