1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 19:50:56 +00:00

add comments & change channel from 100 to 1000

This commit is contained in:
astaxie 2013-12-19 00:43:29 +08:00
parent 7242bc862e
commit de0113ae6a

View File

@ -40,13 +40,13 @@ type controllerInfo struct {
} }
type ControllerRegistor struct { type ControllerRegistor struct {
routers []*controllerInfo routers []*controllerInfo // regexp router storage
fixrouters []*controllerInfo fixrouters []*controllerInfo // fixed router storage
enableFilter bool enableFilter bool
filters map[int][]*FilterRouter filters map[int][]*FilterRouter
enableAuto bool enableAuto bool
autoRouter map[string]map[string]reflect.Type //key:controller key:method value:reflect.type autoRouter map[string]map[string]reflect.Type //key:controller key:method value:reflect.type
contextBuffer chan *beecontext.Context contextBuffer chan *beecontext.Context //context buffer pool
} }
func NewControllerRegistor() *ControllerRegistor { func NewControllerRegistor() *ControllerRegistor {
@ -54,7 +54,7 @@ func NewControllerRegistor() *ControllerRegistor {
routers: make([]*controllerInfo, 0), routers: make([]*controllerInfo, 0),
autoRouter: make(map[string]map[string]reflect.Type), autoRouter: make(map[string]map[string]reflect.Type),
filters: make(map[int][]*FilterRouter), filters: make(map[int][]*FilterRouter),
contextBuffer: make(chan *beecontext.Context, 100), contextBuffer: make(chan *beecontext.Context, 1000),
} }
} }
@ -213,6 +213,10 @@ func (p *ControllerRegistor) Add(pattern string, c ControllerInterface, mappingM
} }
// add auto router to controller // add auto router to controller
// example beego.AddAuto(&MainContorlller{})
// MainController has method List and Page
// you can visit the url /main/list to exec List function
// /main/page to exec Page function
func (p *ControllerRegistor) AddAuto(c ControllerInterface) { func (p *ControllerRegistor) AddAuto(c ControllerInterface) {
p.enableAuto = true p.enableAuto = true
reflectVal := reflect.ValueOf(c) reflectVal := reflect.ValueOf(c)
@ -367,7 +371,7 @@ func (p *ControllerRegistor) UrlFor(endpoint string, values ...string) string {
return "" return ""
} }
// AutoRoute // main function to serveHTTP
func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) { func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
defer func() { defer func() {
if err := recover(); err != nil { if err := recover(); err != nil {