Go語言應用框架,beego 1.4.0 版本發布
這個版本整整憋了兩個月時間,主要是我們真的做了好多功能性上面的改進,這里要感謝所有給beego貢獻的用戶,也感謝給beego持續提各種改進意見的用戶,下面是我們這次改進的特性
1. bee工具的完整性改進,bee現在支持了如下功能:
bee api 直接從數據庫讀取數據庫表,一鍵生成API應用帶文檔,詳細介紹看視頻:http://www.tudou.com/programs/view/aM7iKLlBlrU/
bee generate命令,這個是新增加的命令,可以用來自動化生成代碼,主要有如下子命令:
- scaffold 類似其他框架的腳手架功能,生成controller、model、view、migration
- model 生成CRUD的model
- controller 生成CRUD的controller
- view 生成CRUD的view文件,內容為空,需要用戶自己做UI界面
- migration 生成migration文件
- appcode 從數據庫根據表結構生成model、controller、router
- docs 從controller注釋自動化生成swagger文檔
bee migrate 命令,執行migration,支持如下子命令
- migrate 執行所有新的migration
- rollback 回滾最后一次執行的migration
- reset 回滾所有的migration
- refresh 回滾所有的migration并從頭執行全部的migration
bee run改進,默認支持了watchall功能,增加了兩個參數gendoc和downdoc
2. config模塊增加新的接口,現在config模塊支持如下接口,支持直接保存文件:
type ConfigContainer interface { Set(key, val string) error // support section::key type in given key when using ini type. String(key string) string // support section::key type in key string when using ini and json type; Int,Int64,Bool,Float,DIY are same. Strings(key string) []string //get string slice Int(key string) (int, error) Int64(key string) (int64, error) Bool(key string) (bool, error) Float(key string) (float64, error) DefaultString(key string, defaultval string) string // support section::key type in key string when using ini and json type; Int,Int64,Bool,Float,DIY are same. DefaultStrings(key string, defaultval []string) []string //get string slice DefaultInt(key string, defaultval int) int DefaultInt64(key string, defaultval int64) int64 DefaultBool(key string, defaultval bool) bool DefaultFloat(key string, defaultval float64) float64 DIY(key string) (interface{}, error) GetSection(section string) (map[string]string, error) SaveConfigFile(filename string) error }
3. middleware中支持另一種i18n的支持:
I18N = middleware.NewLocale("conf/i18n.conf", beego.AppConfig.String("language"))
配置文件如下:
{ "E-mail Address": { "en": "E-mail Address", "zh": "郵箱地址", "vn": "?????" }, "Username": { "en": "Ussername", "zh": "用戶名", "vn": "tên truy nh?p" } }
使用如下:
I18N.Translate("username", "vn")
4. namespace前綴支持正則:
beego.NewNamespace("/v1/:uid", beego.NSNamespace("/customer", beego.NSInclude( &controllers.CustomerController{}, &controllers.CustomerCookieCheckerController{}, ), ), )
5. cache和session模塊的memcache、redis引擎修改到最新版本的驅動
6. 增加開發打印路由調試功能:
2014/08/22 09:55:40 [I] | GET | / | 7.660221504s | match | / | 2014/08/22 09:55:40 [I] | GET | / | 13.421869836s | match | / | 2014/08/22 09:55:40 [I] | GET | / | 1.726185752s | match | / | 2014/08/22 09:55:40 [I] | GET | /user/login| 7.494079ms | match | /user/login |
7. log 的等級符合RFC5424規范
8. 靜態文件處理支持robots.txt,用戶放在static目錄下即可
9. 增加和簡化plugins功能:
auth 支持basicauth,詳細使用請看https://godoc.org/github.com/astaxie/beego/plugins/auth
cors 支持跨站調用,詳細使用請看https://godoc.org/github.com/astaxie/beego/plugins/cors
10. 新增了AdminUI,用戶在EnableAdmin的情況下,可以通過界面簡單地獲取當前應用的各種狀態,同時可以很容易的調試性能,監控系統,執行任務,獲取配置等
11. session配置現在支持設置cookie domain
12. 新增migration包,支持migration的功能
13. getconfg方法改為public方法,用戶就可以通過改方法獲取相應runmode下的配置文件
14. 改進httplib的方法支持SetAgent和BasicAuth的請求,httplib支持請求一次,讀取多次
修復bug:
1. file session在部分情況下內容消失問題
2. docs自動化生成,文件不更新
3. 路由namespace的前綴不支持
4. orm修正detect engine
5. 修復captcha里面當用戶驗證碼輸入長度不對時不進行更新
6. 調用setstatus之后后面調用的setHeader全部無效的問題
7. 修復smtp發送郵件需要驗證的情況
8. 修復utils下safemap的items問題
8. 修復geturl函數當參數多個時不帶?的問題
beego是一個用Go開發的應用框架,思路來自于tornado,路由設計來源于sinatra,支持如下特性
- MVC
- REST
- 智能路由
- 日志調試
- 配置管理
- 模板自動渲染
- layout設計
- 中間件插入邏輯
- 方便的JSON/XML服務
官網 http://beego.me
來自:http://www.oschina.net/news/54657/beego-1-4-0