Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
de0113ae
Commit
de0113ae
authored
Dec 18, 2013
by
astaxie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add comments & change channel from 100 to 1000
parent
7242bc86
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
5 deletions
+9
-5
router.go
router.go
+9
-5
No files found.
router.go
View file @
de0113ae
...
...
@@ -40,13 +40,13 @@ type controllerInfo struct {
}
type
ControllerRegistor
struct
{
routers
[]
*
controllerInfo
fixrouters
[]
*
controllerInfo
routers
[]
*
controllerInfo
// regexp router storage
fixrouters
[]
*
controllerInfo
// fixed router storage
enableFilter
bool
filters
map
[
int
][]
*
FilterRouter
enableAuto
bool
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
{
...
...
@@ -54,7 +54,7 @@ func NewControllerRegistor() *ControllerRegistor {
routers
:
make
([]
*
controllerInfo
,
0
),
autoRouter
:
make
(
map
[
string
]
map
[
string
]
reflect
.
Type
),
filters
:
make
(
map
[
int
][]
*
FilterRouter
),
contextBuffer
:
make
(
chan
*
beecontext
.
Context
,
100
),
contextBuffer
:
make
(
chan
*
beecontext
.
Context
,
100
0
),
}
}
...
...
@@ -213,6 +213,10 @@ func (p *ControllerRegistor) Add(pattern string, c ControllerInterface, mappingM
}
// 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
)
{
p
.
enableAuto
=
true
reflectVal
:=
reflect
.
ValueOf
(
c
)
...
...
@@ -367,7 +371,7 @@ func (p *ControllerRegistor) UrlFor(endpoint string, values ...string) string {
return
""
}
//
AutoRoute
//
main function to serveHTTP
func
(
p
*
ControllerRegistor
)
ServeHTTP
(
rw
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
defer
func
()
{
if
err
:=
recover
();
err
!=
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment