红联Linux门户
Linux帮助

beego 0.5版本发布,Go应用框架

发布时间:2013-04-10 11:07:44来源:红联作者:empast
近期对beego进行了大量的新特性开发,主要功能有
新增
1、支持自定义http.Handler,这样就可以方便的集成其他系统,例如sockjs,beego里面有example写了一个聊天室,相当的简单
2、模板引擎新增三个函数str2html、htmlquote、htmlunquote
3、模板引擎缓存问题,在dev模式下不缓存,用户无须重新编译程序
4、路由函数由以前的RegisterController修改为Router,同时兼容老的接口
5、session操作新增三个方便的函数:SetSession/GetSession/DelSession
6、读取模板渲染的结果新增函数RenderString,返回渲染后的字符串信息,方便用户缓存为静态html
7、session模块从astaxie/session中迁移到beego中,同时实现了四种引擎的session:memory、file、redis、mysql
8、表单新增四个方便获取数据的接口函数:GetString、GetInt、GetBool、GetFile
9、路由功能的进一步加强,支持如下集中方式路由

beego.Router("/news/:all", &controllers.RController{}) //匹配 /news/path/to/123.html :all= path/to/123.html
beego.Router("/user/:username([\w]+)", &controllers.RController{}) //匹配 /user/astaxie :username = astaxie
beego.Router("/download/*.*", &controllers.RController{}) //匹配 /download/file/api.xml :path= file/api :ext=xml
beego.Router("/download/ceshi/*", &controllers.RController{}) //匹配 /download/ceshi/file/api.json :splat=file/api.json
beego.Router("/:id:int", &controllers.RController{}) //匹配 :id为int类型,框架帮你实现了正则([0-9]+)
beego.Router("/:hi:string", &controllers.RController{}) //匹配 :hi为string类型。框架帮你实现了正则([\w]+)

bug修复
1、路由规则中一个字符的时候存在bug /:id([0-9]+)这种规则,如果url为/3就无法获取的bug
2、form表单如果是multipart的时候无法获取内容

项目主页:https://github.com/astaxie/beego

来自:开源中国社区
文章评论

共有 0 条评论