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
152127c2
Commit
152127c2
authored
Sep 07, 2015
by
astaxie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make golint happy
parent
919675e7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
19 deletions
+20
-19
admin.go
admin.go
+2
-2
app.go
app.go
+11
-10
beego.go
beego.go
+6
-5
hooks.go
hooks.go
+1
-2
No files found.
admin.go
View file @
152127c2
...
...
@@ -314,14 +314,14 @@ func profIndex(rw http.ResponseWriter, r *http.Request) {
data
[
"Content"
]
=
result
.
String
()
if
format
==
"json"
&&
command
==
"gc summary"
{
dataJ
son
,
err
:=
json
.
Marshal
(
data
)
dataJ
SON
,
err
:=
json
.
Marshal
(
data
)
if
err
!=
nil
{
http
.
Error
(
rw
,
err
.
Error
(),
http
.
StatusInternalServerError
)
return
}
rw
.
Header
()
.
Set
(
"Content-Type"
,
"application/json"
)
rw
.
Write
(
dataJ
son
)
rw
.
Write
(
dataJ
SON
)
return
}
...
...
app.go
View file @
152127c2
...
...
@@ -28,6 +28,7 @@ import (
)
var
(
// BeeApp is an application instance
BeeApp
*
App
)
...
...
@@ -202,7 +203,7 @@ func Router(rootpath string, c ControllerInterface, mappingMethods ...string) *A
return
BeeApp
}
//
Router add list from
//
Include will generate router file in the router/xxx.go from the controller's comments
// usage:
// beego.Include(&BankAccount{}, &OrderController{},&RefundController{},&ReceiptController{})
// type BankAccount struct{
...
...
@@ -261,7 +262,7 @@ func AutoPrefix(prefix string, c ControllerInterface) *App {
return
BeeApp
}
// register router for Get method
//
Get used to
register router for Get method
// usage:
// beego.Get("/", func(ctx *context.Context){
// ctx.Output.Body("hello world")
...
...
@@ -271,7 +272,7 @@ func Get(rootpath string, f FilterFunc) *App {
return
BeeApp
}
// register router for Post method
//
Post used to
register router for Post method
// usage:
// beego.Post("/api", func(ctx *context.Context){
// ctx.Output.Body("hello world")
...
...
@@ -281,7 +282,7 @@ func Post(rootpath string, f FilterFunc) *App {
return
BeeApp
}
// register router for Delete method
//
Delete used to
register router for Delete method
// usage:
// beego.Delete("/api", func(ctx *context.Context){
// ctx.Output.Body("hello world")
...
...
@@ -291,7 +292,7 @@ func Delete(rootpath string, f FilterFunc) *App {
return
BeeApp
}
// register router for Put method
//
Put used to
register router for Put method
// usage:
// beego.Put("/api", func(ctx *context.Context){
// ctx.Output.Body("hello world")
...
...
@@ -301,7 +302,7 @@ func Put(rootpath string, f FilterFunc) *App {
return
BeeApp
}
// register router for Head method
//
Head used to
register router for Head method
// usage:
// beego.Head("/api", func(ctx *context.Context){
// ctx.Output.Body("hello world")
...
...
@@ -311,7 +312,7 @@ func Head(rootpath string, f FilterFunc) *App {
return
BeeApp
}
// register router for Options method
//
Options used to
register router for Options method
// usage:
// beego.Options("/api", func(ctx *context.Context){
// ctx.Output.Body("hello world")
...
...
@@ -321,7 +322,7 @@ func Options(rootpath string, f FilterFunc) *App {
return
BeeApp
}
// register router for Patch method
//
Patch used to
register router for Patch method
// usage:
// beego.Patch("/api", func(ctx *context.Context){
// ctx.Output.Body("hello world")
...
...
@@ -331,7 +332,7 @@ func Patch(rootpath string, f FilterFunc) *App {
return
BeeApp
}
//
register router for all method
//
Any used to register router for all methods
// usage:
// beego.Any("/api", func(ctx *context.Context){
// ctx.Output.Body("hello world")
...
...
@@ -341,7 +342,7 @@ func Any(rootpath string, f FilterFunc) *App {
return
BeeApp
}
//
register router for own Handl
er
//
Handler used to register a Handler rout
er
// usage:
// beego.Handler("/api", func(ctx *context.Context){
// ctx.Output.Body("hello world")
...
...
beego.go
View file @
152127c2
...
...
@@ -31,7 +31,8 @@ var (
hooks
=
make
([]
hookfunc
,
0
)
//hook function slice to store the hookfunc
)
// The hookfunc will run in beego.Run()
// AddAPPStartHook is used to register the hookfunc
// The hookfuncs will run in beego.Run()
// such as sessionInit, middlerware start, buildtemplate, admin start
func
AddAPPStartHook
(
hf
hookfunc
)
{
hooks
=
append
(
hooks
,
hf
)
...
...
@@ -42,7 +43,7 @@ func AddAPPStartHook(hf hookfunc) {
// beego.Run(":8089")
// beego.Run("127.0.0.1:8089")
func
Run
(
params
...
string
)
{
initBeforeH
ttp
Run
()
initBeforeH
TTP
Run
()
if
len
(
params
)
>
0
&&
params
[
0
]
!=
""
{
strs
:=
strings
.
Split
(
params
[
0
],
":"
)
...
...
@@ -57,7 +58,7 @@ func Run(params ...string) {
BeeApp
.
Run
()
}
func
initBeforeH
ttp
Run
()
{
func
initBeforeH
TTP
Run
()
{
// if AppConfigPath not In the conf/app.conf reParse config
if
AppConfigPath
!=
filepath
.
Join
(
AppPath
,
"conf"
,
"app.conf"
)
{
err
:=
ParseConfig
()
...
...
@@ -82,7 +83,7 @@ func initBeforeHttpRun() {
}
}
//
this function
is for test package init
//
TestBeegoInit
is for test package init
func
TestBeegoInit
(
apppath
string
)
{
AppPath
=
apppath
os
.
Setenv
(
"BEEGO_RUNMODE"
,
"test"
)
...
...
@@ -93,5 +94,5 @@ func TestBeegoInit(apppath string) {
Info
(
err
)
}
os
.
Chdir
(
AppPath
)
initBeforeH
ttp
Run
()
initBeforeH
TTP
Run
()
}
hooks.go
View file @
152127c2
...
...
@@ -71,8 +71,7 @@ func registerSession() error {
`"domain":"`
+
SessionDomain
+
`",`
+
`"cookieLifeTime":`
+
strconv
.
Itoa
(
SessionCookieLifeTime
)
+
`}`
}
GlobalSessions
,
err
=
session
.
NewManager
(
SessionProvider
,
sessionConfig
)
GlobalSessions
,
err
=
session
.
NewManager
(
SessionProvider
,
sessionConfig
)
if
err
!=
nil
{
return
err
}
...
...
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