Skip to content

Commit

Permalink
Add a guide for beego integration.
Browse files Browse the repository at this point in the history
  • Loading branch information
leekchan committed Jul 31, 2015
1 parent b422204 commit dc3362e
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,64 @@ func init() {
```


### [Beego](http://beego.me/) integration

Add these three lines before "beego.Run()" in your main() function. This code snippet injects gtf functions into beego's FuncMap.

```Go
for k, v := range gtf.GtfFuncMap {
beego.AddFuncMap(k, v)
}
```

**Full example:**

```Go
package main

import (
"github.com/astaxie/beego"
"github.com/beego/i18n"

"github.com/beego/samples/WebIM/controllers"

"github.com/leekchan/gtf"
)

const (
APP_VER = "0.1.1.0227"
)

func main() {
beego.Info(beego.AppName, APP_VER)

// Register routers.
beego.Router("/", &controllers.AppController{})
// Indicate AppController.Join method to handle POST requests.
beego.Router("/join", &controllers.AppController{}, "post:Join")

// Long polling.
beego.Router("/lp", &controllers.LongPollingController{}, "get:Join")
beego.Router("/lp/post", &controllers.LongPollingController{})
beego.Router("/lp/fetch", &controllers.LongPollingController{}, "get:Fetch")

// WebSocket.
beego.Router("/ws", &controllers.WebSocketController{})
beego.Router("/ws/join", &controllers.WebSocketController{}, "get:Join")

// Register template functions.
beego.AddFuncMap("i18n", i18n.Tr)

// Register gtf functions.
for k, v := range gtf.GtfFuncMap {
beego.AddFuncMap(k, v)
}

beego.Run()
}
```


### Other web frameworks (TODO)

I will add the detailed integration guides for other web frameworks soon!
Expand Down

0 comments on commit dc3362e

Please sign in to comment.