ohana 是一个返回模拟 json 数据的 node http 服务器,默认集成了 mockjs 生成动态的 json 数据,支持 POST, GET, PUT, DELETE 四种请求。
github: https://github.com/Allenice/ohana
特点:
使用 mockjs 生成 json 数据支持路由规则可跨域访问匹配 GET 方式的请求。
path: 路由匹配地址options: delay: 延迟多少毫秒后返回,data: 返回的数据,可以接受对象和方法, 方法中的参数 params 是路由匹配的参数,query 是提交或查询的参数。与 get 同理
与 get 同理
与 get 同理
Basic string:
"/articles" will only match routes that == "/articles".Named parameters:
"/articles/:title" will only match routes like "/articles/hello", but *not* "/articles/".Optional named parameters:
"/articles/:title?" will match "/articles/hello" AND "/articles/"Periods before optional parameters are also optional:
"/:n.:f?" will match "/1" and "/1.json"Splaaaat! :
"/assets/*" will match "/assets/blah/blah/blah.png" and "/assets/". "/assets/*.*" will match "/assets/1/2/3.js" as splats: ["1/2/3", "js"]Mix splat with named parameters:
"/account/:id/assets/*" will match "/account/2/assets/folder.png" as params: {id: 2}, splats:["folder.png"]Named RegExp:
"/lang/:lang([a-z]{2})" will match "/lang/en" but not "/lang/12" or "/lang/eng"Raw RegExp:
/^\/(\d{2,3}-\d{2,3}-\d{4})\.(\w*)$/ (note no quotes, this is a RegExp, not a string.) will match "/123-22-1234.json". Each match group will be an entry in splats: ["123-22-1234", "json"]参考: https://github.com/aaronblohowiak/routes.js
ohana 默认集成了 mockjs,你可以使用 mockjs 生成 json 数据。当然你也可以使用其他的生成工具。 参考文档: http://mockjs.com/editor.html#help
原文:http://blog.allenice233.com/2014/12/01/ohana-node-server/
转载于:https://www.cnblogs.com/allenice/p/4139918.html
相关资源:DirectX修复工具V4.0增强版