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
107a7a21
Commit
107a7a21
authored
Jun 10, 2014
by
astaxie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
beego: dev mode print request router & pattern
parent
dbebf8df
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
3 deletions
+15
-3
parser.go
parser.go
+1
-1
router.go
router.go
+14
-2
No files found.
parser.go
View file @
107a7a21
...
...
@@ -165,7 +165,7 @@ func compareFile(pkgRealpath string) bool {
return
true
}
if
v
,
ok
:=
pkgLastupdate
[
pkgRealpath
];
ok
{
if
ft
.
ModTime
()
.
UnixNano
()
>
v
{
if
ft
.
ModTime
()
.
UnixNano
()
>
=
v
{
return
false
}
}
...
...
router.go
View file @
107a7a21
...
...
@@ -60,6 +60,7 @@ func ExceptMethodAppend(action string) {
}
type
controllerInfo
struct
{
pattern
string
controllerType
reflect
.
Type
methods
map
[
string
]
string
handler
http
.
Handler
...
...
@@ -119,6 +120,7 @@ func (p *ControllerRegistor) Add(pattern string, c ControllerInterface, mappingM
}
route
:=
&
controllerInfo
{}
route
.
pattern
=
pattern
route
.
methods
=
methods
route
.
routerType
=
routerTypeBeego
route
.
controllerType
=
t
...
...
@@ -273,6 +275,7 @@ func (p *ControllerRegistor) AddMethod(method, pattern string, f FilterFunc) {
panic
(
"not support http method: "
+
method
)
}
route
:=
&
controllerInfo
{}
route
.
pattern
=
pattern
route
.
routerType
=
routerTypeRESTFul
route
.
runfunction
=
f
methods
:=
make
(
map
[
string
]
string
)
...
...
@@ -298,6 +301,7 @@ func (p *ControllerRegistor) AddMethod(method, pattern string, f FilterFunc) {
// add user defined Handler
func
(
p
*
ControllerRegistor
)
Handler
(
pattern
string
,
h
http
.
Handler
,
options
...
interface
{})
{
route
:=
&
controllerInfo
{}
route
.
pattern
=
pattern
route
.
routerType
=
routerTypeHandler
route
.
handler
=
h
if
len
(
options
)
>
0
{
...
...
@@ -336,6 +340,7 @@ func (p *ControllerRegistor) AddAutoPrefix(prefix string, c ControllerInterface)
route
.
methods
=
map
[
string
]
string
{
"*"
:
rt
.
Method
(
i
)
.
Name
}
route
.
controllerType
=
ct
pattern
:=
path
.
Join
(
prefix
,
controllerName
,
strings
.
ToLower
(
rt
.
Method
(
i
)
.
Name
),
"*"
)
route
.
pattern
=
pattern
for
_
,
m
:=
range
HTTPMETHOD
{
p
.
addToRouter
(
m
,
pattern
,
route
)
}
...
...
@@ -502,7 +507,6 @@ func (p *ControllerRegistor) geturl(t *Tree, url, controllName, methodName strin
// Implement http.Handler interface.
func
(
p
*
ControllerRegistor
)
ServeHTTP
(
rw
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
defer
p
.
recoverPanic
(
rw
,
r
)
starttime
:=
time
.
Now
()
requestPath
:=
r
.
URL
.
Path
method
:=
strings
.
ToLower
(
r
.
Method
)
...
...
@@ -718,9 +722,9 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
do_filter
(
FinishRouter
)
Admin
:
timeend
:=
time
.
Since
(
starttime
)
//admin module record QPS
if
EnableAdmin
{
timeend
:=
time
.
Since
(
starttime
)
if
FilterMonitorFunc
(
r
.
Method
,
requestPath
,
timeend
)
{
if
runrouter
!=
nil
{
go
toolbox
.
StatisticsMap
.
AddStatistics
(
r
.
Method
,
requestPath
,
runrouter
.
Name
(),
timeend
)
...
...
@@ -729,6 +733,14 @@ Admin:
}
}
}
if
RunMode
==
"dev"
{
if
findrouter
{
Info
(
"beego: router defined "
+
routerInfo
.
pattern
+
" "
+
requestPath
+
" +"
+
timeend
.
String
())
}
else
{
Info
(
"beego:"
+
requestPath
+
" 404"
+
" +"
+
timeend
.
String
())
}
}
}
func
(
p
*
ControllerRegistor
)
recoverPanic
(
rw
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
...
...
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