Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
张磊
/
FileStorageBeego
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
419c3fc7
authored
2013-12-21 00:34:59 +0800
by
astaxie
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
remove contextBuffer fix #396
1 parent
2ad399db
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
36 deletions
router.go
router.go
View file @
419c3fc
...
...
@@ -40,21 +40,19 @@ type controllerInfo struct {
}
type
ControllerRegistor
struct
{
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
//context buffer pool
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
}
func
NewControllerRegistor
()
*
ControllerRegistor
{
return
&
ControllerRegistor
{
routers
:
make
([]
*
controllerInfo
,
0
),
autoRouter
:
make
(
map
[
string
]
map
[
string
]
reflect
.
Type
),
filters
:
make
(
map
[
int
][]
*
FilterRouter
),
contextBuffer
:
make
(
chan
*
beecontext
.
Context
,
1000
),
routers
:
make
([]
*
controllerInfo
,
0
),
autoRouter
:
make
(
map
[
string
]
map
[
string
]
reflect
.
Type
),
filters
:
make
(
map
[
int
][]
*
FilterRouter
),
}
}
...
...
@@ -440,31 +438,14 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
w
.
Header
()
.
Set
(
"Server"
,
BeegoServerName
)
// init context
var
context
*
beecontext
.
Context
select
{
case
context
=
<-
p
.
contextBuffer
:
context
.
ResponseWriter
=
w
context
.
Request
=
r
context
.
Input
.
Request
=
r
default
:
context
=
&
beecontext
.
Context
{
ResponseWriter
:
w
,
Request
:
r
,
Input
:
beecontext
.
NewInput
(
r
),
Output
:
beecontext
.
NewOutput
(),
}
context
.
Output
.
Context
=
context
context
.
Output
.
EnableGzip
=
EnableGzip
}
defer
func
()
{
if
context
!=
nil
{
select
{
case
p
.
contextBuffer
<-
context
:
default
:
}
}
}()
context
:=
&
beecontext
.
Context
{
ResponseWriter
:
w
,
Request
:
r
,
Input
:
beecontext
.
NewInput
(
r
),
Output
:
beecontext
.
NewOutput
(),
}
context
.
Output
.
Context
=
context
context
.
Output
.
EnableGzip
=
EnableGzip
if
context
.
Input
.
IsWebsocket
()
{
context
.
ResponseWriter
=
rw
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
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 post a comment