设为首页收藏本站

LUPA开源社区

 找回密码
 注册
文章 帖子 博客
LUPA开源社区 首页 业界资讯 软件追踪 查看内容

hi-nginx-1.7.8发布,嵌入duktape引擎,支持js开发

2018-12-26 23:13| 发布者: joejoe0332| 查看: 406| 评论: 0|原作者: oschina|来自: oschina

摘要: hi-nginx-1.7.8发布了。这一次更新的重点嵌入javascript引擎duktape,因而支持使用js进行web应用开发。通过以下四个命令开启duktape支持:hi_duktape_package_path 配置js文件模块搜索路径(js模块写法与nodejs一致)h ...

hi-nginx-1.7.8发布了。

这一次更新的重点嵌入javascript引擎duktape,因而支持使用js进行web应用开发。通过以下四个命令开启duktape支持:

  • hi_duktape_package_path 配置js文件模块搜索路径(js模块写法与nodejs一致)

  • hi_duktape_package_cpath 配置动态库模块搜索路径(动态库模块基于duktape c接口,但可以同时支持c++)

  • hi_duktape_content 运行js内容块

  • hi_duktape_script 运行js文件

duktape web开发的接口与python和lua保持一致。例子:

/*
 var foo = require('foo')
 hi_res.header('Content-Type','text/plain;charset=UTF-8')
 hi_res.content(foo.hello())
 hi_res.status(200)
*/


/*
 var mustache = require('mustache')
 var template = '<h1>Test mustache engine</h1><p>{{body}}</p>';
 var model = {body:'Hello World'};
 hi_res.content(mustache.to_html(template,model))
 hi_res.status(200)
 */

/*
 var handlebars = require('handlebars')
 var template = handlebars.compile('<h1>Test handlebars engine</h1><p>{{body}}</p>')
 var model = {body:'Hello World'};
 hi_res.content(template(model))
 hi_res.status(200)
 */


/*
 var echo = require('echo')
 var t=new echo()
 t.set('HELLO, ')
 hi_res.content(t.concat('Tom'))
 hi_res.status(200)
 */



/*

var route = require('route').get_instance()

route.get('^\/get/?(\\w+)$', function (req, res, param) {
    res.header('Content-Type', 'text/plain;charset=UTF8')
    res.content(req.method()+'\n'+req.uri() + '\n' + param.toString())
    res.status(200)
})

route.post('^\/post/?([a-zA-Z]+)?$', function (req, res, param) {
    res.header('Content-Type', 'text/plain;charset=UTF8')
    res.content(req.method()+'\n'+req.uri() + '\n' + param.toString())
    res.status(200)
})

route.put('^\/put/?([0-9]+)?', function (req, res, param) {
    res.header('Content-Type', 'text/plain;charset=UTF8')
    res.content(req.method()+'\n'+req.uri() + '\n' + param.toString())
    res.status(200)
})

route.add(['GET', 'POST', 'PUT'], '^\/(.*)$', function (req, res, param) {
    res.header('Content-Type', 'text/plain;charset=UTF8')
    res.content(req.method()+'\n'+req.uri() + '\n' + param.toString())
    res.status(200)
})

route.run(hi_req, hi_res)


*/

/*

var loaded = hi_module.require('demo', 'cpp')
var registered = cpp()
if (loaded && registered) {
    var a = new demo()
    hi_res.header('Content-Type', 'text/plain;charset=UTF-8')
    hi_res.content(a.echo('hello,cpp class'))
    hi_res.status(200)
    hi_module.free(a)
}

*/

///*
 hi_res.header('Content-Type','text/plain;charset=UTF-8')
 hi_res.content('hello,world')
 hi_res.status(200)
//*/

酷毙

雷人

鲜花

鸡蛋

漂亮
  • 快毕业了,没工作经验,
    找份工作好难啊?
    赶紧去人才芯片公司磨练吧!!

最新评论

关于LUPA|人才芯片工程|人才招聘|LUPA认证|LUPA教育|LUPA开源社区 ( 浙B2-20090187 浙公网安备 33010602006705号   

返回顶部