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
e2672049
Commit
e2672049
authored
Sep 19, 2015
by
astaxie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove the dupl
parent
8af8936e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
93 deletions
+33
-93
admin.go
admin.go
+33
-93
No files found.
admin.go
View file @
e2672049
...
...
@@ -65,24 +65,15 @@ func init() {
// AdminIndex is the default http.Handler for admin module.
// it matches url pattern "/".
func
adminIndex
(
rw
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
tmpl
:=
template
.
Must
(
template
.
New
(
"dashboard"
)
.
Parse
(
dashboardTpl
))
tmpl
=
template
.
Must
(
tmpl
.
Parse
(
indexTpl
))
tmpl
=
template
.
Must
(
tmpl
.
Parse
(
defaultScriptsTpl
))
data
:=
make
(
map
[
interface
{}]
interface
{})
tmpl
.
Execute
(
rw
,
data
)
execTpl
(
rw
,
map
[
interface
{}]
interface
{}{},
indexTpl
,
defaultScriptsTpl
)
}
// QpsIndex is the http.Handler for writing qbs statistics map result info in http.ResponseWriter.
// it's registered with url pattern "/qbs" in admin module.
func
qpsIndex
(
rw
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
tmpl
:=
template
.
Must
(
template
.
New
(
"dashboard"
)
.
Parse
(
dashboardTpl
))
tmpl
=
template
.
Must
(
tmpl
.
Parse
(
qpsTpl
))
tmpl
=
template
.
Must
(
tmpl
.
Parse
(
defaultScriptsTpl
))
data
:=
make
(
map
[
interface
{}]
interface
{})
data
[
"Content"
]
=
toolbox
.
StatisticsMap
.
GetMap
()
tmpl
.
Execute
(
rw
,
data
)
execTpl
(
rw
,
data
,
qpsTpl
,
defaultScriptsTpl
)
}
// ListConf is the http.Handler of displaying all beego configuration values as key/value pair.
...
...
@@ -167,11 +158,7 @@ func listConf(rw http.ResponseWriter, r *http.Request) {
content
[
"Methods"
]
=
methods
data
[
"Content"
]
=
content
data
[
"Title"
]
=
"Routers"
tmpl
:=
template
.
Must
(
template
.
New
(
"dashboard"
)
.
Parse
(
dashboardTpl
))
tmpl
=
template
.
Must
(
tmpl
.
Parse
(
routerAndFilterTpl
))
tmpl
=
template
.
Must
(
tmpl
.
Parse
(
defaultScriptsTpl
))
tmpl
.
Execute
(
rw
,
data
)
execTpl
(
rw
,
data
,
routerAndFilterTpl
,
defaultScriptsTpl
)
case
"filter"
:
content
:=
make
(
map
[
string
]
interface
{})
...
...
@@ -186,65 +173,25 @@ func listConf(rw http.ResponseWriter, r *http.Request) {
if
BeeApp
.
Handlers
.
enableFilter
{
var
filterType
string
if
bf
,
ok
:=
BeeApp
.
Handlers
.
filters
[
BeforeRouter
];
ok
{
filterType
=
"Before Router"
filterTypes
=
append
(
filterTypes
,
filterType
)
resultList
:=
new
([][]
string
)
for
_
,
f
:=
range
bf
{
var
result
=
[]
string
{
fmt
.
Sprintf
(
"%s"
,
f
.
pattern
),
fmt
.
Sprintf
(
"%s"
,
utils
.
GetFuncName
(
f
.
filterFunc
)),
}
*
resultList
=
append
(
*
resultList
,
result
)
}
filterTypeData
[
filterType
]
=
resultList
}
if
bf
,
ok
:=
BeeApp
.
Handlers
.
filters
[
BeforeExec
];
ok
{
filterType
=
"Before Exec"
filterTypes
=
append
(
filterTypes
,
filterType
)
resultList
:=
new
([][]
string
)
for
_
,
f
:=
range
bf
{
var
result
=
[]
string
{
fmt
.
Sprintf
(
"%s"
,
f
.
pattern
),
fmt
.
Sprintf
(
"%s"
,
utils
.
GetFuncName
(
f
.
filterFunc
)),
}
*
resultList
=
append
(
*
resultList
,
result
)
}
filterTypeData
[
filterType
]
=
resultList
}
if
bf
,
ok
:=
BeeApp
.
Handlers
.
filters
[
AfterExec
];
ok
{
filterType
=
"After Exec"
filterTypes
=
append
(
filterTypes
,
filterType
)
resultList
:=
new
([][]
string
)
for
_
,
f
:=
range
bf
{
var
result
=
[]
string
{
fmt
.
Sprintf
(
"%s"
,
f
.
pattern
),
fmt
.
Sprintf
(
"%s"
,
utils
.
GetFuncName
(
f
.
filterFunc
)),
for
k
,
fr
:=
range
map
[
int
]
string
{
BeforeStatic
:
"Before Static"
,
BeforeRouter
:
"Before Router"
,
BeforeExec
:
"Before Exec"
,
AfterExec
:
"After Exec"
,
FinishRouter
:
"Finish Router"
}
{
if
bf
,
ok
:=
BeeApp
.
Handlers
.
filters
[
k
];
ok
{
filterType
=
fr
filterTypes
=
append
(
filterTypes
,
filterType
)
resultList
:=
new
([][]
string
)
for
_
,
f
:=
range
bf
{
var
result
=
[]
string
{
fmt
.
Sprintf
(
"%s"
,
f
.
pattern
),
fmt
.
Sprintf
(
"%s"
,
utils
.
GetFuncName
(
f
.
filterFunc
)),
}
*
resultList
=
append
(
*
resultList
,
result
)
}
*
resultList
=
append
(
*
resultList
,
result
)
filterTypeData
[
filterType
]
=
resultList
}
filterTypeData
[
filterType
]
=
resultList
}
if
bf
,
ok
:=
BeeApp
.
Handlers
.
filters
[
FinishRouter
];
ok
{
filterType
=
"Finish Router"
filterTypes
=
append
(
filterTypes
,
filterType
)
resultList
:=
new
([][]
string
)
for
_
,
f
:=
range
bf
{
var
result
=
[]
string
{
fmt
.
Sprintf
(
"%s"
,
f
.
pattern
),
fmt
.
Sprintf
(
"%s"
,
utils
.
GetFuncName
(
f
.
filterFunc
)),
}
*
resultList
=
append
(
*
resultList
,
result
)
}
filterTypeData
[
filterType
]
=
resultList
}
}
...
...
@@ -253,11 +200,7 @@ func listConf(rw http.ResponseWriter, r *http.Request) {
data
[
"Content"
]
=
content
data
[
"Title"
]
=
"Filters"
tmpl
:=
template
.
Must
(
template
.
New
(
"dashboard"
)
.
Parse
(
dashboardTpl
))
tmpl
=
template
.
Must
(
tmpl
.
Parse
(
routerAndFilterTpl
))
tmpl
=
template
.
Must
(
tmpl
.
Parse
(
defaultScriptsTpl
))
tmpl
.
Execute
(
rw
,
data
)
execTpl
(
rw
,
data
,
routerAndFilterTpl
,
defaultScriptsTpl
)
default
:
rw
.
Write
([]
byte
(
"command not support"
))
}
...
...
@@ -306,7 +249,7 @@ func profIndex(rw http.ResponseWriter, r *http.Request) {
r
.
ParseForm
()
command
:=
r
.
Form
.
Get
(
"command"
)
format
:=
r
.
Form
.
Get
(
"format"
)
data
:=
make
(
map
[
string
]
interface
{})
data
:=
make
(
map
[
interface
{}
]
interface
{})
var
result
bytes
.
Buffer
if
command
!=
""
{
...
...
@@ -326,15 +269,11 @@ func profIndex(rw http.ResponseWriter, r *http.Request) {
}
data
[
"Title"
]
=
command
tmpl
:=
template
.
Must
(
template
.
New
(
"dashboard"
)
.
Parse
(
dashboardTpl
))
tmpl
=
template
.
Must
(
tmpl
.
Parse
(
profillingTpl
))
defaultTpl
:=
defaultScriptsTpl
if
command
==
"gc summary"
{
tmpl
=
template
.
Must
(
tmpl
.
Parse
(
gcAjaxTpl
))
}
else
{
tmpl
=
template
.
Must
(
tmpl
.
Parse
(
defaultScriptsTpl
))
defaultTpl
=
gcAjaxTpl
}
tmpl
.
Execute
(
rw
,
data
)
execTpl
(
rw
,
data
,
profillingTpl
,
defaultTpl
)
}
}
...
...
@@ -376,11 +315,7 @@ func healthcheck(rw http.ResponseWriter, req *http.Request) {
content
[
"Data"
]
=
resultList
data
[
"Content"
]
=
content
data
[
"Title"
]
=
"Health Check"
tmpl
:=
template
.
Must
(
template
.
New
(
"dashboard"
)
.
Parse
(
dashboardTpl
))
tmpl
=
template
.
Must
(
tmpl
.
Parse
(
healthCheckTpl
))
tmpl
=
template
.
Must
(
tmpl
.
Parse
(
defaultScriptsTpl
))
tmpl
.
Execute
(
rw
,
data
)
execTpl
(
rw
,
data
,
healthCheckTpl
,
defaultScriptsTpl
)
}
// TaskStatus is a http.Handler with running task status (task name, status and the last execution).
...
...
@@ -429,9 +364,14 @@ func taskStatus(rw http.ResponseWriter, req *http.Request) {
content
[
"Data"
]
=
resultList
data
[
"Content"
]
=
content
data
[
"Title"
]
=
"Tasks"
execTpl
(
rw
,
data
,
tasksTpl
,
defaultScriptsTpl
)
}
func
execTpl
(
rw
http
.
ResponseWriter
,
data
map
[
interface
{}]
interface
{},
tpls
...
string
)
{
tmpl
:=
template
.
Must
(
template
.
New
(
"dashboard"
)
.
Parse
(
dashboardTpl
))
tmpl
=
template
.
Must
(
tmpl
.
Parse
(
tasksTpl
))
tmpl
=
template
.
Must
(
tmpl
.
Parse
(
defaultScriptsTpl
))
for
_
,
tpl
:=
range
tpls
{
tmpl
=
template
.
Must
(
tmpl
.
Parse
(
tpl
))
}
tmpl
.
Execute
(
rw
,
data
)
}
...
...
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