Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
二次元的罪恶王冠
beego
提交
5a863b45
B
beego
项目概览
二次元的罪恶王冠
/
beego
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
B
beego
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5a863b45
编写于
4月 06, 2014
作者:
A
astaxie
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
beego: BeeAdminApp private
上级
3ad30d48
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
24 addition
and
24 deletion
+24
-24
admin.go
admin.go
+23
-23
beego.go
beego.go
+1
-1
未找到文件。
admin.go
浏览文件 @
5a863b45
...
...
@@ -9,8 +9,8 @@ import (
"github.com/astaxie/beego/utils"
)
// BeeAdminApp is the default
A
dminApp used by admin module.
var
BeeAdminApp
*
A
dminApp
// BeeAdminApp is the default
a
dminApp used by admin module.
var
beeAdminApp
*
a
dminApp
// FilterMonitorFunc is default monitor filter when admin module is enable.
// if this func returns, admin module records qbs for this request by condition of this function logic.
...
...
@@ -31,22 +31,22 @@ var BeeAdminApp *AdminApp
var
FilterMonitorFunc
func
(
string
,
string
,
time
.
Duration
)
bool
func
init
()
{
BeeAdminApp
=
&
A
dminApp
{
beeAdminApp
=
&
a
dminApp
{
routers
:
make
(
map
[
string
]
http
.
HandlerFunc
),
}
BeeAdminApp
.
Route
(
"/"
,
A
dminIndex
)
BeeAdminApp
.
Route
(
"/qps"
,
Q
psIndex
)
BeeAdminApp
.
Route
(
"/prof"
,
P
rofIndex
)
BeeAdminApp
.
Route
(
"/healthcheck"
,
H
ealthcheck
)
BeeAdminApp
.
Route
(
"/task"
,
T
askStatus
)
BeeAdminApp
.
Route
(
"/runtask"
,
R
unTask
)
BeeAdminApp
.
Route
(
"/listconf"
,
L
istConf
)
beeAdminApp
.
Route
(
"/"
,
a
dminIndex
)
beeAdminApp
.
Route
(
"/qps"
,
q
psIndex
)
beeAdminApp
.
Route
(
"/prof"
,
p
rofIndex
)
beeAdminApp
.
Route
(
"/healthcheck"
,
h
ealthcheck
)
beeAdminApp
.
Route
(
"/task"
,
t
askStatus
)
beeAdminApp
.
Route
(
"/runtask"
,
r
unTask
)
beeAdminApp
.
Route
(
"/listconf"
,
l
istConf
)
FilterMonitorFunc
=
func
(
string
,
string
,
time
.
Duration
)
bool
{
return
true
}
}
// AdminIndex is the default http.Handler for admin module.
// it matches url pattern "/".
func
A
dminIndex
(
rw
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
func
a
dminIndex
(
rw
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
rw
.
Write
([]
byte
(
"Welcome to Admin Dashboard
\n
"
))
rw
.
Write
([]
byte
(
"There are servral functions:
\n
"
))
rw
.
Write
([]
byte
(
"1. Record all request and request time, http://localhost:8088/qps
\n
"
))
...
...
@@ -60,13 +60,13 @@ func AdminIndex(rw http.ResponseWriter, r *http.Request) {
// 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
Q
psIndex
(
rw
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
func
q
psIndex
(
rw
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
toolbox
.
StatisticsMap
.
GetMap
(
rw
)
}
// ListConf is the http.Handler of displaying all beego configuration values as key/value pair.
// it's registered with url pattern "/listconf" in admin module.
func
L
istConf
(
rw
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
func
l
istConf
(
rw
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
r
.
ParseForm
()
command
:=
r
.
Form
.
Get
(
"command"
)
if
command
!=
""
{
...
...
@@ -183,7 +183,7 @@ func ListConf(rw http.ResponseWriter, r *http.Request) {
// ProfIndex is a http.Handler for showing profile command.
// it's in url pattern "/prof" in admin module.
func
P
rofIndex
(
rw
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
func
p
rofIndex
(
rw
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
r
.
ParseForm
()
command
:=
r
.
Form
.
Get
(
"command"
)
if
command
!=
""
{
...
...
@@ -204,7 +204,7 @@ func ProfIndex(rw http.ResponseWriter, r *http.Request) {
// Healthcheck is a http.Handler calling health checking and showing the result.
// it's in "/healthcheck" pattern in admin module.
func
H
ealthcheck
(
rw
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
func
h
ealthcheck
(
rw
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
for
name
,
h
:=
range
toolbox
.
AdminCheckList
{
if
err
:=
h
.
Check
();
err
!=
nil
{
fmt
.
Fprintf
(
rw
,
"%s : ok
\n
"
,
name
)
...
...
@@ -216,7 +216,7 @@ func Healthcheck(rw http.ResponseWriter, req *http.Request) {
// TaskStatus is a http.Handler with running task status (task name, status and the last execution).
// it's in "/task" pattern in admin module.
func
T
askStatus
(
rw
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
func
t
askStatus
(
rw
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
for
tname
,
tk
:=
range
toolbox
.
AdminTaskList
{
fmt
.
Fprintf
(
rw
,
"%s:%s:%s"
,
tname
,
tk
.
GetStatus
(),
tk
.
GetPrev
()
.
String
())
}
...
...
@@ -224,7 +224,7 @@ func TaskStatus(rw http.ResponseWriter, req *http.Request) {
// RunTask is a http.Handler to run a Task from the "query string.
// the request url likes /runtask?taskname=sendmail.
func
R
unTask
(
rw
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
func
r
unTask
(
rw
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
req
.
ParseForm
()
taskname
:=
req
.
Form
.
Get
(
"taskname"
)
if
t
,
ok
:=
toolbox
.
AdminTaskList
[
taskname
];
ok
{
...
...
@@ -238,19 +238,19 @@ func RunTask(rw http.ResponseWriter, req *http.Request) {
}
}
//
AdminApp is an http.HandlerFunc map used as B
eeAdminApp.
type
A
dminApp
struct
{
//
adminApp is an http.HandlerFunc map used as b
eeAdminApp.
type
a
dminApp
struct
{
routers
map
[
string
]
http
.
HandlerFunc
}
// Route adds http.HandlerFunc to
A
dminApp with url pattern.
func
(
admin
*
A
dminApp
)
Route
(
pattern
string
,
f
http
.
HandlerFunc
)
{
// Route adds http.HandlerFunc to
a
dminApp with url pattern.
func
(
admin
*
a
dminApp
)
Route
(
pattern
string
,
f
http
.
HandlerFunc
)
{
admin
.
routers
[
pattern
]
=
f
}
// Run
A
dminApp http server.
// Run
a
dminApp http server.
// Its addr is defined in configuration file as adminhttpaddr and adminhttpport.
func
(
admin
*
A
dminApp
)
Run
()
{
func
(
admin
*
a
dminApp
)
Run
()
{
if
len
(
toolbox
.
AdminTaskList
)
>
0
{
toolbox
.
StartTask
()
}
...
...
beego.go
浏览文件 @
5a863b45
...
...
@@ -179,7 +179,7 @@ func Run() {
initBeforeHttpRun
()
if
EnableAdmin
{
go
B
eeAdminApp
.
Run
()
go
b
eeAdminApp
.
Run
()
}
BeeApp
.
Run
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录