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