摘要:
模块是可以被插入到应用程序的包. 他们允许在多个Revel应用或第三方程序中共享controller、view、资源文件和其他代码模块应该有相同的布局来作为一个Revel应用程序. 主应用程序将把模块按照下面的方式合并:任何在module/app/views中的模板将被添加到模板加载器的搜索路径任何在module/app/controllers中的controller将被视为他们在你的应用程序中通过一个路由的形式 staticDir:modulename:public,资源文件就可以使用了开启一个module为了添加一个模块到你的应用程序,添加如下一行代码到app.conf:module.my 阅读全文
随笔档案-2013年1月8日
Go Web开发之Revel - Websockets
2013-01-08 17:31 by Danny.tian, 1567 阅读, 收藏,
摘要:
Revel 支持Websockets.处理一个Websocket连接:使用WS方法添加一个路由.添加一个action接受一个*websocket.Conn参数.例如添加如下代码到你的routes文件:WS /app/feed Application.Feed然后写一个action就下下面:import "code.google.com/p/go.net/websocket"func (c Application) Feed(user string, ws *websocket.Conn) rev.Result { ...}至此结束。 阅读全文
Go Web开发之Revel - 插件
2013-01-08 13:19 by Danny.tian, 1982 阅读, 收藏,
摘要:
插件被注册到应用程序的hook上面和请求生命周期事件离.一个插件就像下面的接口 (每一个事件都将被通知):type Plugin interface { // Server启动时被call (每一次代码重新加载). OnAppStart() // 路由器完成配置后被call. OnRoutesLoaded(router *Router) // 每一次request之前被call. BeforeRequest(c *Controller) // 每一次request之后被call.(除了panics) AfterRequest(c *Control... 阅读全文
浙公网安备 33010602011771号