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
3b29a9c1
Commit
3b29a9c1
authored
Apr 24, 2017
by
eyalpost
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/develop' into develop
parents
864693d2
d03285a0
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
134 additions
and
124 deletions
+134
-124
admin.go
admin.go
+4
-6
ini.go
config/ini.go
+1
-1
server.go
grace/server.go
+0
-1
jianliao.go
logs/jianliao.go
+0
-2
slack.go
logs/slack.go
+0
-2
smtp.go
logs/smtp.go
+0
-2
namespace.go
namespace.go
+5
-6
db_alias.go
orm/db_alias.go
+2
-0
router.go
router.go
+27
-29
router_test.go
router_test.go
+9
-1
sess_couchbase.go
session/couchbase/sess_couchbase.go
+6
-4
ledis_session.go
session/ledis/ledis_session.go
+23
-24
sess_memcache.go
session/memcache/sess_memcache.go
+0
-1
sess_mysql.go
session/mysql/sess_mysql.go
+0
-1
sess_postgresql.go
session/postgres/sess_postgresql.go
+0
-1
sess_redis.go
session/redis/sess_redis.go
+13
-20
sess_cookie.go
session/sess_cookie.go
+9
-15
sess_ssdb.go
session/ssdb/sess_ssdb.go
+5
-6
staticfile.go
staticfile.go
+0
-2
utils.go
utils/utils.go
+30
-0
No files found.
admin.go
View file @
3b29a9c1
...
@@ -208,7 +208,7 @@ func printTree(resultList *[][]string, t *Tree) {
...
@@ -208,7 +208,7 @@ func printTree(resultList *[][]string, t *Tree) {
printTree
(
resultList
,
t
.
wildcard
)
printTree
(
resultList
,
t
.
wildcard
)
}
}
for
_
,
l
:=
range
t
.
leaves
{
for
_
,
l
:=
range
t
.
leaves
{
if
v
,
ok
:=
l
.
runObject
.
(
*
c
ontrollerInfo
);
ok
{
if
v
,
ok
:=
l
.
runObject
.
(
*
C
ontrollerInfo
);
ok
{
if
v
.
routerType
==
routerTypeBeego
{
if
v
.
routerType
==
routerTypeBeego
{
var
result
=
[]
string
{
var
result
=
[]
string
{
v
.
pattern
,
v
.
pattern
,
...
@@ -276,8 +276,8 @@ func profIndex(rw http.ResponseWriter, r *http.Request) {
...
@@ -276,8 +276,8 @@ func profIndex(rw http.ResponseWriter, r *http.Request) {
// it's in "/healthcheck" pattern in admin module.
// it's in "/healthcheck" pattern in admin module.
func
healthcheck
(
rw
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
func
healthcheck
(
rw
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
var
(
var
(
result
[]
string
data
=
make
(
map
[
interface
{}]
interface
{})
data
=
make
(
map
[
interface
{}]
interface
{})
result
=
[]
string
{}
resultList
=
new
([][]
string
)
resultList
=
new
([][]
string
)
content
=
map
[
string
]
interface
{}{
content
=
map
[
string
]
interface
{}{
"Fields"
:
[]
string
{
"Name"
,
"Message"
,
"Status"
},
"Fields"
:
[]
string
{
"Name"
,
"Message"
,
"Status"
},
...
@@ -291,17 +291,16 @@ func healthcheck(rw http.ResponseWriter, req *http.Request) {
...
@@ -291,17 +291,16 @@ func healthcheck(rw http.ResponseWriter, req *http.Request) {
name
,
name
,
err
.
Error
(),
err
.
Error
(),
}
}
}
else
{
}
else
{
result
=
[]
string
{
result
=
[]
string
{
"success"
,
"success"
,
name
,
name
,
"OK"
,
"OK"
,
}
}
}
}
*
resultList
=
append
(
*
resultList
,
result
)
*
resultList
=
append
(
*
resultList
,
result
)
}
}
content
[
"Data"
]
=
resultList
content
[
"Data"
]
=
resultList
data
[
"Content"
]
=
content
data
[
"Content"
]
=
content
data
[
"Title"
]
=
"Health Check"
data
[
"Title"
]
=
"Health Check"
...
@@ -330,7 +329,6 @@ func taskStatus(rw http.ResponseWriter, req *http.Request) {
...
@@ -330,7 +329,6 @@ func taskStatus(rw http.ResponseWriter, req *http.Request) {
// List Tasks
// List Tasks
content
:=
make
(
map
[
string
]
interface
{})
content
:=
make
(
map
[
string
]
interface
{})
resultList
:=
new
([][]
string
)
resultList
:=
new
([][]
string
)
var
result
=
[]
string
{}
var
fields
=
[]
string
{
var
fields
=
[]
string
{
"Task Name"
,
"Task Name"
,
"Task Spec"
,
"Task Spec"
,
...
@@ -339,7 +337,7 @@ func taskStatus(rw http.ResponseWriter, req *http.Request) {
...
@@ -339,7 +337,7 @@ func taskStatus(rw http.ResponseWriter, req *http.Request) {
""
,
""
,
}
}
for
tname
,
tk
:=
range
toolbox
.
AdminTaskList
{
for
tname
,
tk
:=
range
toolbox
.
AdminTaskList
{
result
=
[]
string
{
result
:
=
[]
string
{
tname
,
tname
,
tk
.
GetSpec
(),
tk
.
GetSpec
(),
tk
.
GetStatus
(),
tk
.
GetStatus
(),
...
...
config/ini.go
View file @
3b29a9c1
...
@@ -421,7 +421,7 @@ func (c *IniConfigContainer) Set(key, value string) error {
...
@@ -421,7 +421,7 @@ func (c *IniConfigContainer) Set(key, value string) error {
var
(
var
(
section
,
k
string
section
,
k
string
sectionKey
=
strings
.
Split
(
key
,
"::"
)
sectionKey
=
strings
.
Split
(
strings
.
ToLower
(
key
)
,
"::"
)
)
)
if
len
(
sectionKey
)
>=
2
{
if
len
(
sectionKey
)
>=
2
{
...
...
grace/server.go
View file @
3b29a9c1
...
@@ -196,7 +196,6 @@ func (srv *Server) signalHooks(ppFlag int, sig os.Signal) {
...
@@ -196,7 +196,6 @@ func (srv *Server) signalHooks(ppFlag int, sig os.Signal) {
for
_
,
f
:=
range
srv
.
SignalHooks
[
ppFlag
][
sig
]
{
for
_
,
f
:=
range
srv
.
SignalHooks
[
ppFlag
][
sig
]
{
f
()
f
()
}
}
return
}
}
// shutdown closes the listener so that no new connections are accepted. it also
// shutdown closes the listener so that no new connections are accepted. it also
...
...
logs/jianliao.go
View file @
3b29a9c1
...
@@ -61,12 +61,10 @@ func (s *JLWriter) WriteMsg(when time.Time, msg string, level int) error {
...
@@ -61,12 +61,10 @@ func (s *JLWriter) WriteMsg(when time.Time, msg string, level int) error {
// Flush implementing method. empty.
// Flush implementing method. empty.
func
(
s
*
JLWriter
)
Flush
()
{
func
(
s
*
JLWriter
)
Flush
()
{
return
}
}
// Destroy implementing method. empty.
// Destroy implementing method. empty.
func
(
s
*
JLWriter
)
Destroy
()
{
func
(
s
*
JLWriter
)
Destroy
()
{
return
}
}
func
init
()
{
func
init
()
{
...
...
logs/slack.go
View file @
3b29a9c1
...
@@ -49,12 +49,10 @@ func (s *SLACKWriter) WriteMsg(when time.Time, msg string, level int) error {
...
@@ -49,12 +49,10 @@ func (s *SLACKWriter) WriteMsg(when time.Time, msg string, level int) error {
// Flush implementing method. empty.
// Flush implementing method. empty.
func
(
s
*
SLACKWriter
)
Flush
()
{
func
(
s
*
SLACKWriter
)
Flush
()
{
return
}
}
// Destroy implementing method. empty.
// Destroy implementing method. empty.
func
(
s
*
SLACKWriter
)
Destroy
()
{
func
(
s
*
SLACKWriter
)
Destroy
()
{
return
}
}
func
init
()
{
func
init
()
{
...
...
logs/smtp.go
View file @
3b29a9c1
...
@@ -138,12 +138,10 @@ func (s *SMTPWriter) WriteMsg(when time.Time, msg string, level int) error {
...
@@ -138,12 +138,10 @@ func (s *SMTPWriter) WriteMsg(when time.Time, msg string, level int) error {
// Flush implementing method. empty.
// Flush implementing method. empty.
func
(
s
*
SMTPWriter
)
Flush
()
{
func
(
s
*
SMTPWriter
)
Flush
()
{
return
}
}
// Destroy implementing method. empty.
// Destroy implementing method. empty.
func
(
s
*
SMTPWriter
)
Destroy
()
{
func
(
s
*
SMTPWriter
)
Destroy
()
{
return
}
}
func
init
()
{
func
init
()
{
...
...
namespace.go
View file @
3b29a9c1
...
@@ -267,13 +267,12 @@ func addPrefix(t *Tree, prefix string) {
...
@@ -267,13 +267,12 @@ func addPrefix(t *Tree, prefix string) {
addPrefix
(
t
.
wildcard
,
prefix
)
addPrefix
(
t
.
wildcard
,
prefix
)
}
}
for
_
,
l
:=
range
t
.
leaves
{
for
_
,
l
:=
range
t
.
leaves
{
if
c
,
ok
:=
l
.
runObject
.
(
*
c
ontrollerInfo
);
ok
{
if
c
,
ok
:=
l
.
runObject
.
(
*
C
ontrollerInfo
);
ok
{
if
!
strings
.
HasPrefix
(
c
.
pattern
,
prefix
)
{
if
!
strings
.
HasPrefix
(
c
.
pattern
,
prefix
)
{
c
.
pattern
=
prefix
+
c
.
pattern
c
.
pattern
=
prefix
+
c
.
pattern
}
}
}
}
}
}
}
}
// NSCond is Namespace Condition
// NSCond is Namespace Condition
...
@@ -284,16 +283,16 @@ func NSCond(cond namespaceCond) LinkNamespace {
...
@@ -284,16 +283,16 @@ func NSCond(cond namespaceCond) LinkNamespace {
}
}
// NSBefore Namespace BeforeRouter filter
// NSBefore Namespace BeforeRouter filter
func
NSBefore
(
fil
i
terList
...
FilterFunc
)
LinkNamespace
{
func
NSBefore
(
filterList
...
FilterFunc
)
LinkNamespace
{
return
func
(
ns
*
Namespace
)
{
return
func
(
ns
*
Namespace
)
{
ns
.
Filter
(
"before"
,
fil
i
terList
...
)
ns
.
Filter
(
"before"
,
filterList
...
)
}
}
}
}
// NSAfter add Namespace FinishRouter filter
// NSAfter add Namespace FinishRouter filter
func
NSAfter
(
fil
i
terList
...
FilterFunc
)
LinkNamespace
{
func
NSAfter
(
filterList
...
FilterFunc
)
LinkNamespace
{
return
func
(
ns
*
Namespace
)
{
return
func
(
ns
*
Namespace
)
{
ns
.
Filter
(
"after"
,
fil
i
terList
...
)
ns
.
Filter
(
"after"
,
filterList
...
)
}
}
}
}
...
...
orm/db_alias.go
View file @
3b29a9c1
...
@@ -60,6 +60,8 @@ var (
...
@@ -60,6 +60,8 @@ var (
"sqlite3"
:
DRSqlite
,
"sqlite3"
:
DRSqlite
,
"tidb"
:
DRTiDB
,
"tidb"
:
DRTiDB
,
"oracle"
:
DROracle
,
"oracle"
:
DROracle
,
"oci8"
:
DROracle
,
// github.com/mattn/go-oci8
"ora"
:
DROracle
,
//https://github.com/rana/ora
}
}
dbBasers
=
map
[
DriverType
]
dbBaser
{
dbBasers
=
map
[
DriverType
]
dbBaser
{
DRMySQL
:
newdbBaseMysql
(),
DRMySQL
:
newdbBaseMysql
(),
...
...
router.go
View file @
3b29a9c1
...
@@ -17,7 +17,6 @@ package beego
...
@@ -17,7 +17,6 @@ package beego
import
(
import
(
"fmt"
"fmt"
"net/http"
"net/http"
"os"
"path"
"path"
"path/filepath"
"path/filepath"
"reflect"
"reflect"
...
@@ -111,7 +110,8 @@ func ExceptMethodAppend(action string) {
...
@@ -111,7 +110,8 @@ func ExceptMethodAppend(action string) {
exceptMethod
=
append
(
exceptMethod
,
action
)
exceptMethod
=
append
(
exceptMethod
,
action
)
}
}
type
controllerInfo
struct
{
// ControllerInfo holds information about the controller.
type
ControllerInfo
struct
{
pattern
string
pattern
string
controllerType
reflect
.
Type
controllerType
reflect
.
Type
methods
map
[
string
]
string
methods
map
[
string
]
string
...
@@ -183,7 +183,7 @@ func (p *ControllerRegister) addWithMethodParams(pattern string, c ControllerInt
...
@@ -183,7 +183,7 @@ func (p *ControllerRegister) addWithMethodParams(pattern string, c ControllerInt
}
}
}
}
route
:=
&
c
ontrollerInfo
{}
route
:=
&
C
ontrollerInfo
{}
route
.
pattern
=
pattern
route
.
pattern
=
pattern
route
.
methods
=
methods
route
.
methods
=
methods
route
.
routerType
=
routerTypeBeego
route
.
routerType
=
routerTypeBeego
...
@@ -206,7 +206,7 @@ func (p *ControllerRegister) addWithMethodParams(pattern string, c ControllerInt
...
@@ -206,7 +206,7 @@ func (p *ControllerRegister) addWithMethodParams(pattern string, c ControllerInt
}
}
}
}
func
(
p
*
ControllerRegister
)
addToRouter
(
method
,
pattern
string
,
r
*
c
ontrollerInfo
)
{
func
(
p
*
ControllerRegister
)
addToRouter
(
method
,
pattern
string
,
r
*
C
ontrollerInfo
)
{
if
!
BConfig
.
RouterCaseSensitive
{
if
!
BConfig
.
RouterCaseSensitive
{
pattern
=
strings
.
ToLower
(
pattern
)
pattern
=
strings
.
ToLower
(
pattern
)
}
}
...
@@ -227,13 +227,11 @@ func (p *ControllerRegister) Include(cList ...ControllerInterface) {
...
@@ -227,13 +227,11 @@ func (p *ControllerRegister) Include(cList ...ControllerInterface) {
for
_
,
c
:=
range
cList
{
for
_
,
c
:=
range
cList
{
reflectVal
:=
reflect
.
ValueOf
(
c
)
reflectVal
:=
reflect
.
ValueOf
(
c
)
t
:=
reflect
.
Indirect
(
reflectVal
)
.
Type
()
t
:=
reflect
.
Indirect
(
reflectVal
)
.
Type
()
gopath
:=
os
.
Getenv
(
"GOPATH"
)
wgopath
:=
utils
.
GetGOPATHs
(
)
if
gopath
==
""
{
if
len
(
wgopath
)
==
0
{
panic
(
"you are in dev mode. So please set gopath"
)
panic
(
"you are in dev mode. So please set gopath"
)
}
}
pkgpath
:=
""
pkgpath
:=
""
wgopath
:=
filepath
.
SplitList
(
gopath
)
for
_
,
wg
:=
range
wgopath
{
for
_
,
wg
:=
range
wgopath
{
wg
,
_
=
filepath
.
EvalSymlinks
(
filepath
.
Join
(
wg
,
"src"
,
t
.
PkgPath
()))
wg
,
_
=
filepath
.
EvalSymlinks
(
filepath
.
Join
(
wg
,
"src"
,
t
.
PkgPath
()))
if
utils
.
FileExists
(
wg
)
{
if
utils
.
FileExists
(
wg
)
{
...
@@ -343,7 +341,7 @@ func (p *ControllerRegister) AddMethod(method, pattern string, f FilterFunc) {
...
@@ -343,7 +341,7 @@ func (p *ControllerRegister) AddMethod(method, pattern string, f FilterFunc) {
if
_
,
ok
:=
HTTPMETHOD
[
method
];
method
!=
"*"
&&
!
ok
{
if
_
,
ok
:=
HTTPMETHOD
[
method
];
method
!=
"*"
&&
!
ok
{
panic
(
"not support http method: "
+
method
)
panic
(
"not support http method: "
+
method
)
}
}
route
:=
&
c
ontrollerInfo
{}
route
:=
&
C
ontrollerInfo
{}
route
.
pattern
=
pattern
route
.
pattern
=
pattern
route
.
routerType
=
routerTypeRESTFul
route
.
routerType
=
routerTypeRESTFul
route
.
runFunction
=
f
route
.
runFunction
=
f
...
@@ -369,7 +367,7 @@ func (p *ControllerRegister) AddMethod(method, pattern string, f FilterFunc) {
...
@@ -369,7 +367,7 @@ func (p *ControllerRegister) AddMethod(method, pattern string, f FilterFunc) {
// Handler add user defined Handler
// Handler add user defined Handler
func
(
p
*
ControllerRegister
)
Handler
(
pattern
string
,
h
http
.
Handler
,
options
...
interface
{})
{
func
(
p
*
ControllerRegister
)
Handler
(
pattern
string
,
h
http
.
Handler
,
options
...
interface
{})
{
route
:=
&
c
ontrollerInfo
{}
route
:=
&
C
ontrollerInfo
{}
route
.
pattern
=
pattern
route
.
pattern
=
pattern
route
.
routerType
=
routerTypeHandler
route
.
routerType
=
routerTypeHandler
route
.
handler
=
h
route
.
handler
=
h
...
@@ -404,7 +402,7 @@ func (p *ControllerRegister) AddAutoPrefix(prefix string, c ControllerInterface)
...
@@ -404,7 +402,7 @@ func (p *ControllerRegister) AddAutoPrefix(prefix string, c ControllerInterface)
controllerName
:=
strings
.
TrimSuffix
(
ct
.
Name
(),
"Controller"
)
controllerName
:=
strings
.
TrimSuffix
(
ct
.
Name
(),
"Controller"
)
for
i
:=
0
;
i
<
rt
.
NumMethod
();
i
++
{
for
i
:=
0
;
i
<
rt
.
NumMethod
();
i
++
{
if
!
utils
.
InSlice
(
rt
.
Method
(
i
)
.
Name
,
exceptMethod
)
{
if
!
utils
.
InSlice
(
rt
.
Method
(
i
)
.
Name
,
exceptMethod
)
{
route
:=
&
c
ontrollerInfo
{}
route
:=
&
C
ontrollerInfo
{}
route
.
routerType
=
routerTypeBeego
route
.
routerType
=
routerTypeBeego
route
.
methods
=
map
[
string
]
string
{
"*"
:
rt
.
Method
(
i
)
.
Name
}
route
.
methods
=
map
[
string
]
string
{
"*"
:
rt
.
Method
(
i
)
.
Name
}
route
.
controllerType
=
ct
route
.
controllerType
=
ct
...
@@ -510,7 +508,7 @@ func (p *ControllerRegister) geturl(t *Tree, url, controllName, methodName strin
...
@@ -510,7 +508,7 @@ func (p *ControllerRegister) geturl(t *Tree, url, controllName, methodName strin
}
}
}
}
for
_
,
l
:=
range
t
.
leaves
{
for
_
,
l
:=
range
t
.
leaves
{
if
c
,
ok
:=
l
.
runObject
.
(
*
c
ontrollerInfo
);
ok
{
if
c
,
ok
:=
l
.
runObject
.
(
*
C
ontrollerInfo
);
ok
{
if
c
.
routerType
==
routerTypeBeego
&&
if
c
.
routerType
==
routerTypeBeego
&&
strings
.
HasSuffix
(
path
.
Join
(
c
.
controllerType
.
PkgPath
(),
c
.
controllerType
.
Name
()),
controllName
)
{
strings
.
HasSuffix
(
path
.
Join
(
c
.
controllerType
.
PkgPath
(),
c
.
controllerType
.
Name
()),
controllName
)
{
find
:=
false
find
:=
false
...
@@ -638,7 +636,7 @@ func (p *ControllerRegister) ServeHTTP(rw http.ResponseWriter, r *http.Request)
...
@@ -638,7 +636,7 @@ func (p *ControllerRegister) ServeHTTP(rw http.ResponseWriter, r *http.Request)
findRouter
bool
findRouter
bool
runMethod
string
runMethod
string
methodParams
[]
*
param
.
MethodParam
methodParams
[]
*
param
.
MethodParam
routerInfo
*
c
ontrollerInfo
routerInfo
*
C
ontrollerInfo
isRunnable
bool
isRunnable
bool
)
)
context
:=
p
.
pool
.
Get
()
.
(
*
beecontext
.
Context
)
context
:=
p
.
pool
.
Get
()
.
(
*
beecontext
.
Context
)
...
@@ -679,7 +677,7 @@ func (p *ControllerRegister) ServeHTTP(rw http.ResponseWriter, r *http.Request)
...
@@ -679,7 +677,7 @@ func (p *ControllerRegister) ServeHTTP(rw http.ResponseWriter, r *http.Request)
goto
Admin
goto
Admin
}
}
if
r
.
Method
!=
"GET"
&&
r
.
Method
!=
"HEAD"
{
if
r
.
Method
!=
http
.
MethodGet
&&
r
.
Method
!=
http
.
MethodHead
{
if
BConfig
.
CopyRequestBody
&&
!
context
.
Input
.
IsUpload
()
{
if
BConfig
.
CopyRequestBody
&&
!
context
.
Input
.
IsUpload
()
{
context
.
Input
.
CopyBody
(
BConfig
.
MaxMemory
)
context
.
Input
.
CopyBody
(
BConfig
.
MaxMemory
)
}
}
...
@@ -753,11 +751,11 @@ func (p *ControllerRegister) ServeHTTP(rw http.ResponseWriter, r *http.Request)
...
@@ -753,11 +751,11 @@ func (p *ControllerRegister) ServeHTTP(rw http.ResponseWriter, r *http.Request)
runRouter
=
routerInfo
.
controllerType
runRouter
=
routerInfo
.
controllerType
methodParams
=
routerInfo
.
methodParams
methodParams
=
routerInfo
.
methodParams
method
:=
r
.
Method
method
:=
r
.
Method
if
r
.
Method
==
"POST"
&&
context
.
Input
.
Query
(
"_method"
)
==
"PUT"
{
if
r
.
Method
==
http
.
MethodPost
&&
context
.
Input
.
Query
(
"_method"
)
==
http
.
MethodPost
{
method
=
"PUT"
method
=
http
.
MethodPut
}
}
if
r
.
Method
==
"POST"
&&
context
.
Input
.
Query
(
"_method"
)
==
"DELETE"
{
if
r
.
Method
==
http
.
MethodPost
&&
context
.
Input
.
Query
(
"_method"
)
==
http
.
MethodDelete
{
method
=
"DELETE"
method
=
http
.
MethodDelete
}
}
if
m
,
ok
:=
routerInfo
.
methods
[
method
];
ok
{
if
m
,
ok
:=
routerInfo
.
methods
[
method
];
ok
{
runMethod
=
m
runMethod
=
m
...
@@ -787,8 +785,8 @@ func (p *ControllerRegister) ServeHTTP(rw http.ResponseWriter, r *http.Request)
...
@@ -787,8 +785,8 @@ func (p *ControllerRegister) ServeHTTP(rw http.ResponseWriter, r *http.Request)
//if XSRF is Enable then check cookie where there has any cookie in the request's cookie _csrf
//if XSRF is Enable then check cookie where there has any cookie in the request's cookie _csrf
if
BConfig
.
WebConfig
.
EnableXSRF
{
if
BConfig
.
WebConfig
.
EnableXSRF
{
execController
.
XSRFToken
()
execController
.
XSRFToken
()
if
r
.
Method
==
"POST"
||
r
.
Method
==
"DELETE"
||
r
.
Method
==
"PUT"
||
if
r
.
Method
==
http
.
MethodPost
||
r
.
Method
==
http
.
MethodDelete
||
r
.
Method
==
http
.
MethodPut
||
(
r
.
Method
==
"POST"
&&
(
context
.
Input
.
Query
(
"_method"
)
==
"DELETE"
||
context
.
Input
.
Query
(
"_method"
)
==
"PUT"
))
{
(
r
.
Method
==
http
.
MethodPost
&&
(
context
.
Input
.
Query
(
"_method"
)
==
http
.
MethodDelete
||
context
.
Input
.
Query
(
"_method"
)
==
http
.
MethodPut
))
{
execController
.
CheckXSRFCookie
()
execController
.
CheckXSRFCookie
()
}
}
}
}
...
@@ -798,19 +796,19 @@ func (p *ControllerRegister) ServeHTTP(rw http.ResponseWriter, r *http.Request)
...
@@ -798,19 +796,19 @@ func (p *ControllerRegister) ServeHTTP(rw http.ResponseWriter, r *http.Request)
if
!
context
.
ResponseWriter
.
Started
{
if
!
context
.
ResponseWriter
.
Started
{
//exec main logic
//exec main logic
switch
runMethod
{
switch
runMethod
{
case
"GET"
:
case
http
.
MethodGet
:
execController
.
Get
()
execController
.
Get
()
case
"POST"
:
case
http
.
MethodPost
:
execController
.
Post
()
execController
.
Post
()
case
"DELETE"
:
case
http
.
MethodDelete
:
execController
.
Delete
()
execController
.
Delete
()
case
"PUT"
:
case
http
.
MethodPut
:
execController
.
Put
()
execController
.
Put
()
case
"HEAD"
:
case
http
.
MethodHead
:
execController
.
Head
()
execController
.
Head
()
case
"PATCH"
:
case
http
.
MethodPatch
:
execController
.
Patch
()
execController
.
Patch
()
case
"OPTIONS"
:
case
http
.
MethodOptions
:
execController
.
Options
()
execController
.
Options
()
default
:
default
:
if
!
execController
.
HandlerFunc
(
runMethod
)
{
if
!
execController
.
HandlerFunc
(
runMethod
)
{
...
@@ -913,7 +911,7 @@ func (p *ControllerRegister) handleParamResponse(context *beecontext.Context, ex
...
@@ -913,7 +911,7 @@ func (p *ControllerRegister) handleParamResponse(context *beecontext.Context, ex
}
}
// FindRouter Find Router info for URL
// FindRouter Find Router info for URL
func
(
p
*
ControllerRegister
)
FindRouter
(
context
*
beecontext
.
Context
)
(
routerInfo
*
c
ontrollerInfo
,
isFind
bool
)
{
func
(
p
*
ControllerRegister
)
FindRouter
(
context
*
beecontext
.
Context
)
(
routerInfo
*
C
ontrollerInfo
,
isFind
bool
)
{
var
urlPath
=
context
.
Input
.
URL
()
var
urlPath
=
context
.
Input
.
URL
()
if
!
BConfig
.
RouterCaseSensitive
{
if
!
BConfig
.
RouterCaseSensitive
{
urlPath
=
strings
.
ToLower
(
urlPath
)
urlPath
=
strings
.
ToLower
(
urlPath
)
...
@@ -921,7 +919,7 @@ func (p *ControllerRegister) FindRouter(context *beecontext.Context) (routerInfo
...
@@ -921,7 +919,7 @@ func (p *ControllerRegister) FindRouter(context *beecontext.Context) (routerInfo
httpMethod
:=
context
.
Input
.
Method
()
httpMethod
:=
context
.
Input
.
Method
()
if
t
,
ok
:=
p
.
routers
[
httpMethod
];
ok
{
if
t
,
ok
:=
p
.
routers
[
httpMethod
];
ok
{
runObject
:=
t
.
Match
(
urlPath
,
context
)
runObject
:=
t
.
Match
(
urlPath
,
context
)
if
r
,
ok
:=
runObject
.
(
*
c
ontrollerInfo
);
ok
{
if
r
,
ok
:=
runObject
.
(
*
C
ontrollerInfo
);
ok
{
return
r
,
true
return
r
,
true
}
}
}
}
...
...
router_test.go
View file @
3b29a9c1
...
@@ -654,32 +654,40 @@ func TestFilterFinishRouterMulti(t *testing.T) {
...
@@ -654,32 +654,40 @@ func TestFilterFinishRouterMulti(t *testing.T) {
}
}
func
beegoFilterNoOutput
(
ctx
*
context
.
Context
)
{
func
beegoFilterNoOutput
(
ctx
*
context
.
Context
)
{
return
}
}
func
beegoBeforeRouter1
(
ctx
*
context
.
Context
)
{
func
beegoBeforeRouter1
(
ctx
*
context
.
Context
)
{
ctx
.
WriteString
(
"|BeforeRouter1"
)
ctx
.
WriteString
(
"|BeforeRouter1"
)
}
}
func
beegoBeforeRouter2
(
ctx
*
context
.
Context
)
{
func
beegoBeforeRouter2
(
ctx
*
context
.
Context
)
{
ctx
.
WriteString
(
"|BeforeRouter2"
)
ctx
.
WriteString
(
"|BeforeRouter2"
)
}
}
func
beegoBeforeExec1
(
ctx
*
context
.
Context
)
{
func
beegoBeforeExec1
(
ctx
*
context
.
Context
)
{
ctx
.
WriteString
(
"|BeforeExec1"
)
ctx
.
WriteString
(
"|BeforeExec1"
)
}
}
func
beegoBeforeExec2
(
ctx
*
context
.
Context
)
{
func
beegoBeforeExec2
(
ctx
*
context
.
Context
)
{
ctx
.
WriteString
(
"|BeforeExec2"
)
ctx
.
WriteString
(
"|BeforeExec2"
)
}
}
func
beegoAfterExec1
(
ctx
*
context
.
Context
)
{
func
beegoAfterExec1
(
ctx
*
context
.
Context
)
{
ctx
.
WriteString
(
"|AfterExec1"
)
ctx
.
WriteString
(
"|AfterExec1"
)
}
}
func
beegoAfterExec2
(
ctx
*
context
.
Context
)
{
func
beegoAfterExec2
(
ctx
*
context
.
Context
)
{
ctx
.
WriteString
(
"|AfterExec2"
)
ctx
.
WriteString
(
"|AfterExec2"
)
}
}
func
beegoFinishRouter1
(
ctx
*
context
.
Context
)
{
func
beegoFinishRouter1
(
ctx
*
context
.
Context
)
{
ctx
.
WriteString
(
"|FinishRouter1"
)
ctx
.
WriteString
(
"|FinishRouter1"
)
}
}
func
beegoFinishRouter2
(
ctx
*
context
.
Context
)
{
func
beegoFinishRouter2
(
ctx
*
context
.
Context
)
{
ctx
.
WriteString
(
"|FinishRouter2"
)
ctx
.
WriteString
(
"|FinishRouter2"
)
}
}
func
beegoResetParams
(
ctx
*
context
.
Context
)
{
func
beegoResetParams
(
ctx
*
context
.
Context
)
{
ctx
.
ResponseWriter
.
Header
()
.
Set
(
"splat"
,
ctx
.
Input
.
Param
(
":splat"
))
ctx
.
ResponseWriter
.
Header
()
.
Set
(
"splat"
,
ctx
.
Input
.
Param
(
":splat"
))
}
}
...
...
session/couchbase/sess_couchbase.go
View file @
3b29a9c1
...
@@ -155,10 +155,13 @@ func (cp *Provider) SessionInit(maxlifetime int64, savePath string) error {
...
@@ -155,10 +155,13 @@ func (cp *Provider) SessionInit(maxlifetime int64, savePath string) error {
func
(
cp
*
Provider
)
SessionRead
(
sid
string
)
(
session
.
Store
,
error
)
{
func
(
cp
*
Provider
)
SessionRead
(
sid
string
)
(
session
.
Store
,
error
)
{
cp
.
b
=
cp
.
getBucket
()
cp
.
b
=
cp
.
getBucket
()
var
doc
[]
byte
var
(
kv
map
[
interface
{}]
interface
{}
err
error
doc
[]
byte
)
err
:=
cp
.
b
.
Get
(
sid
,
&
doc
)
err
=
cp
.
b
.
Get
(
sid
,
&
doc
)
var
kv
map
[
interface
{}]
interface
{}
if
doc
==
nil
{
if
doc
==
nil
{
kv
=
make
(
map
[
interface
{}]
interface
{})
kv
=
make
(
map
[
interface
{}]
interface
{})
}
else
{
}
else
{
...
@@ -230,7 +233,6 @@ func (cp *Provider) SessionDestroy(sid string) error {
...
@@ -230,7 +233,6 @@ func (cp *Provider) SessionDestroy(sid string) error {
// SessionGC Recycle
// SessionGC Recycle
func
(
cp
*
Provider
)
SessionGC
()
{
func
(
cp
*
Provider
)
SessionGC
()
{
return
}
}
// SessionAll return all active session
// SessionAll return all active session
...
...
session/ledis/ledis_session.go
View file @
3b29a9c1
...
@@ -12,8 +12,10 @@ import (
...
@@ -12,8 +12,10 @@ import (
"github.com/siddontang/ledisdb/ledis"
"github.com/siddontang/ledisdb/ledis"
)
)
var
ledispder
=
&
Provider
{}
var
(
var
c
*
ledis
.
DB
ledispder
=
&
Provider
{}
c
*
ledis
.
DB
)
// SessionStore ledis session store
// SessionStore ledis session store
type
SessionStore
struct
{
type
SessionStore
struct
{
...
@@ -97,27 +99,36 @@ func (lp *Provider) SessionInit(maxlifetime int64, savePath string) error {
...
@@ -97,27 +99,36 @@ func (lp *Provider) SessionInit(maxlifetime int64, savePath string) error {
}
}
cfg
:=
new
(
config
.
Config
)
cfg
:=
new
(
config
.
Config
)
cfg
.
DataDir
=
lp
.
savePath
cfg
.
DataDir
=
lp
.
savePath
nowLedis
,
err
:=
ledis
.
Open
(
cfg
)
c
,
err
=
nowLedis
.
Select
(
lp
.
db
)
var
ledisInstance
*
ledis
.
Ledis
ledisInstance
,
err
=
ledis
.
Open
(
cfg
)
if
err
!=
nil
{
if
err
!=
nil
{
println
(
err
)
return
err
return
nil
}
}
return
nil
c
,
err
=
ledisInstance
.
Select
(
lp
.
db
)
return
err
}
}
// SessionRead read ledis session by sid
// SessionRead read ledis session by sid
func
(
lp
*
Provider
)
SessionRead
(
sid
string
)
(
session
.
Store
,
error
)
{
func
(
lp
*
Provider
)
SessionRead
(
sid
string
)
(
session
.
Store
,
error
)
{
kvs
,
err
:=
c
.
Get
([]
byte
(
sid
))
var
(
var
kv
map
[
interface
{}]
interface
{}
kv
map
[
interface
{}]
interface
{}
kvs
[]
byte
err
error
)
if
kvs
,
err
=
c
.
Get
([]
byte
(
sid
));
err
!=
nil
{
return
nil
,
err
}
if
len
(
kvs
)
==
0
{
if
len
(
kvs
)
==
0
{
kv
=
make
(
map
[
interface
{}]
interface
{})
kv
=
make
(
map
[
interface
{}]
interface
{})
}
else
{
}
else
{
kv
,
err
=
session
.
DecodeGob
(
kvs
)
if
kv
,
err
=
session
.
DecodeGob
(
kvs
);
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
}
}
ls
:=
&
SessionStore
{
sid
:
sid
,
values
:
kv
,
maxlifetime
:
lp
.
maxlifetime
}
ls
:=
&
SessionStore
{
sid
:
sid
,
values
:
kv
,
maxlifetime
:
lp
.
maxlifetime
}
return
ls
,
nil
return
ls
,
nil
}
}
...
@@ -142,18 +153,7 @@ func (lp *Provider) SessionRegenerate(oldsid, sid string) (session.Store, error)
...
@@ -142,18 +153,7 @@ func (lp *Provider) SessionRegenerate(oldsid, sid string) (session.Store, error)
c
.
Set
([]
byte
(
sid
),
data
)
c
.
Set
([]
byte
(
sid
),
data
)
c
.
Expire
([]
byte
(
sid
),
lp
.
maxlifetime
)
c
.
Expire
([]
byte
(
sid
),
lp
.
maxlifetime
)
}
}
kvs
,
err
:=
c
.
Get
([]
byte
(
sid
))
return
lp
.
SessionRead
(
sid
)
var
kv
map
[
interface
{}]
interface
{}
if
len
(
kvs
)
==
0
{
kv
=
make
(
map
[
interface
{}]
interface
{})
}
else
{
kv
,
err
=
session
.
DecodeGob
(
kvs
)
if
err
!=
nil
{
return
nil
,
err
}
}
ls
:=
&
SessionStore
{
sid
:
sid
,
values
:
kv
,
maxlifetime
:
lp
.
maxlifetime
}
return
ls
,
nil
}
}
// SessionDestroy delete ledis session by id
// SessionDestroy delete ledis session by id
...
@@ -164,7 +164,6 @@ func (lp *Provider) SessionDestroy(sid string) error {
...
@@ -164,7 +164,6 @@ func (lp *Provider) SessionDestroy(sid string) error {
// SessionGC Impelment method, no used.
// SessionGC Impelment method, no used.
func
(
lp
*
Provider
)
SessionGC
()
{
func
(
lp
*
Provider
)
SessionGC
()
{
return
}
}
// SessionAll return all active session
// SessionAll return all active session
...
...
session/memcache/sess_memcache.go
View file @
3b29a9c1
...
@@ -215,7 +215,6 @@ func (rp *MemProvider) connectInit() error {
...
@@ -215,7 +215,6 @@ func (rp *MemProvider) connectInit() error {
// SessionGC Impelment method, no used.
// SessionGC Impelment method, no used.
func
(
rp
*
MemProvider
)
SessionGC
()
{
func
(
rp
*
MemProvider
)
SessionGC
()
{
return
}
}
// SessionAll return all activeSession
// SessionAll return all activeSession
...
...
session/mysql/sess_mysql.go
View file @
3b29a9c1
...
@@ -209,7 +209,6 @@ func (mp *Provider) SessionGC() {
...
@@ -209,7 +209,6 @@ func (mp *Provider) SessionGC() {
c
:=
mp
.
connectInit
()
c
:=
mp
.
connectInit
()
c
.
Exec
(
"DELETE from "
+
TableName
+
" where session_expiry < ?"
,
time
.
Now
()
.
Unix
()
-
mp
.
maxlifetime
)
c
.
Exec
(
"DELETE from "
+
TableName
+
" where session_expiry < ?"
,
time
.
Now
()
.
Unix
()
-
mp
.
maxlifetime
)
c
.
Close
()
c
.
Close
()
return
}
}
// SessionAll count values in mysql session
// SessionAll count values in mysql session
...
...
session/postgres/sess_postgresql.go
View file @
3b29a9c1
...
@@ -224,7 +224,6 @@ func (mp *Provider) SessionGC() {
...
@@ -224,7 +224,6 @@ func (mp *Provider) SessionGC() {
c
:=
mp
.
connectInit
()
c
:=
mp
.
connectInit
()
c
.
Exec
(
"DELETE from session where EXTRACT(EPOCH FROM (current_timestamp - session_expiry)) > $1"
,
mp
.
maxlifetime
)
c
.
Exec
(
"DELETE from session where EXTRACT(EPOCH FROM (current_timestamp - session_expiry)) > $1"
,
mp
.
maxlifetime
)
c
.
Close
()
c
.
Close
()
return
}
}
// SessionAll count values in postgresql session
// SessionAll count values in postgresql session
...
...
session/redis/sess_redis.go
View file @
3b29a9c1
...
@@ -155,7 +155,7 @@ func (rp *Provider) SessionInit(maxlifetime int64, savePath string) error {
...
@@ -155,7 +155,7 @@ func (rp *Provider) SessionInit(maxlifetime int64, savePath string) error {
return
nil
,
err
return
nil
,
err
}
}
if
rp
.
password
!=
""
{
if
rp
.
password
!=
""
{
if
_
,
err
:
=
c
.
Do
(
"AUTH"
,
rp
.
password
);
err
!=
nil
{
if
_
,
err
=
c
.
Do
(
"AUTH"
,
rp
.
password
);
err
!=
nil
{
c
.
Close
()
c
.
Close
()
return
nil
,
err
return
nil
,
err
}
}
...
@@ -176,13 +176,20 @@ func (rp *Provider) SessionRead(sid string) (session.Store, error) {
...
@@ -176,13 +176,20 @@ func (rp *Provider) SessionRead(sid string) (session.Store, error) {
c
:=
rp
.
poollist
.
Get
()
c
:=
rp
.
poollist
.
Get
()
defer
c
.
Close
()
defer
c
.
Close
()
kvs
,
err
:=
redis
.
String
(
c
.
Do
(
"GET"
,
sid
))
var
(
var
kv
map
[
interface
{}]
interface
{}
kv
map
[
interface
{}]
interface
{}
kvs
string
err
error
)
if
kvs
,
err
=
redis
.
String
(
c
.
Do
(
"GET"
,
sid
));
err
!=
nil
{
return
nil
,
err
}
if
len
(
kvs
)
==
0
{
if
len
(
kvs
)
==
0
{
kv
=
make
(
map
[
interface
{}]
interface
{})
kv
=
make
(
map
[
interface
{}]
interface
{})
}
else
{
}
else
{
kv
,
err
=
session
.
DecodeGob
([]
byte
(
kvs
))
if
kv
,
err
=
session
.
DecodeGob
([]
byte
(
kvs
));
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
}
}
...
@@ -216,20 +223,7 @@ func (rp *Provider) SessionRegenerate(oldsid, sid string) (session.Store, error)
...
@@ -216,20 +223,7 @@ func (rp *Provider) SessionRegenerate(oldsid, sid string) (session.Store, error)
c
.
Do
(
"RENAME"
,
oldsid
,
sid
)
c
.
Do
(
"RENAME"
,
oldsid
,
sid
)
c
.
Do
(
"EXPIRE"
,
sid
,
rp
.
maxlifetime
)
c
.
Do
(
"EXPIRE"
,
sid
,
rp
.
maxlifetime
)
}
}
return
rp
.
SessionRead
(
sid
)
kvs
,
err
:=
redis
.
String
(
c
.
Do
(
"GET"
,
sid
))
var
kv
map
[
interface
{}]
interface
{}
if
len
(
kvs
)
==
0
{
kv
=
make
(
map
[
interface
{}]
interface
{})
}
else
{
kv
,
err
=
session
.
DecodeGob
([]
byte
(
kvs
))
if
err
!=
nil
{
return
nil
,
err
}
}
rs
:=
&
SessionStore
{
p
:
rp
.
poollist
,
sid
:
sid
,
values
:
kv
,
maxlifetime
:
rp
.
maxlifetime
}
return
rs
,
nil
}
}
// SessionDestroy delete redis session by id
// SessionDestroy delete redis session by id
...
@@ -243,7 +237,6 @@ func (rp *Provider) SessionDestroy(sid string) error {
...
@@ -243,7 +237,6 @@ func (rp *Provider) SessionDestroy(sid string) error {
// SessionGC Impelment method, no used.
// SessionGC Impelment method, no used.
func
(
rp
*
Provider
)
SessionGC
()
{
func
(
rp
*
Provider
)
SessionGC
()
{
return
}
}
// SessionAll return all activeSession
// SessionAll return all activeSession
...
...
session/sess_cookie.go
View file @
3b29a9c1
...
@@ -74,21 +74,16 @@ func (st *CookieSessionStore) SessionID() string {
...
@@ -74,21 +74,16 @@ func (st *CookieSessionStore) SessionID() string {
// SessionRelease Write cookie session to http response cookie
// SessionRelease Write cookie session to http response cookie
func
(
st
*
CookieSessionStore
)
SessionRelease
(
w
http
.
ResponseWriter
)
{
func
(
st
*
CookieSessionStore
)
SessionRelease
(
w
http
.
ResponseWriter
)
{
str
,
err
:=
encodeCookie
(
cookiepder
.
block
,
encodedCookie
,
err
:=
encodeCookie
(
cookiepder
.
block
,
cookiepder
.
config
.
SecurityKey
,
cookiepder
.
config
.
SecurityName
,
st
.
values
)
cookiepder
.
config
.
SecurityKey
,
if
err
==
nil
{
cookiepder
.
config
.
SecurityName
,
cookie
:=
&
http
.
Cookie
{
Name
:
cookiepder
.
config
.
CookieName
,
st
.
values
)
Value
:
url
.
QueryEscape
(
encodedCookie
),
if
err
!=
nil
{
Path
:
"/"
,
return
HttpOnly
:
true
,
Secure
:
cookiepder
.
config
.
Secure
,
MaxAge
:
cookiepder
.
config
.
Maxage
}
http
.
SetCookie
(
w
,
cookie
)
}
}
cookie
:=
&
http
.
Cookie
{
Name
:
cookiepder
.
config
.
CookieName
,
Value
:
url
.
QueryEscape
(
str
),
Path
:
"/"
,
HttpOnly
:
true
,
Secure
:
cookiepder
.
config
.
Secure
,
MaxAge
:
cookiepder
.
config
.
Maxage
}
http
.
SetCookie
(
w
,
cookie
)
return
}
}
type
cookieConfig
struct
{
type
cookieConfig
struct
{
...
@@ -166,7 +161,6 @@ func (pder *CookieProvider) SessionDestroy(sid string) error {
...
@@ -166,7 +161,6 @@ func (pder *CookieProvider) SessionDestroy(sid string) error {
// SessionGC Implement method, no used.
// SessionGC Implement method, no used.
func
(
pder
*
CookieProvider
)
SessionGC
()
{
func
(
pder
*
CookieProvider
)
SessionGC
()
{
return
}
}
// SessionAll Implement method, return 0.
// SessionAll Implement method, return 0.
...
...
session/ssdb/sess_ssdb.go
View file @
3b29a9c1
...
@@ -30,13 +30,13 @@ func (p *SsdbProvider) connectInit() error {
...
@@ -30,13 +30,13 @@ func (p *SsdbProvider) connectInit() error {
}
}
func
(
p
*
SsdbProvider
)
SessionInit
(
maxLifetime
int64
,
savePath
string
)
error
{
func
(
p
*
SsdbProvider
)
SessionInit
(
maxLifetime
int64
,
savePath
string
)
error
{
var
e
error
=
nil
p
.
maxLifetime
=
maxLifetime
p
.
maxLifetime
=
maxLifetime
address
:=
strings
.
Split
(
savePath
,
":"
)
address
:=
strings
.
Split
(
savePath
,
":"
)
p
.
host
=
address
[
0
]
p
.
host
=
address
[
0
]
p
.
port
,
e
=
strconv
.
Atoi
(
address
[
1
])
if
e
!=
nil
{
var
err
error
return
e
if
p
.
port
,
err
=
strconv
.
Atoi
(
address
[
1
]);
err
!=
nil
{
return
err
}
}
return
p
.
connectInit
()
return
p
.
connectInit
()
}
}
...
@@ -78,8 +78,8 @@ func (p *SsdbProvider) SessionExist(sid string) bool {
...
@@ -78,8 +78,8 @@ func (p *SsdbProvider) SessionExist(sid string) bool {
return
false
return
false
}
}
return
true
return
true
}
}
func
(
p
*
SsdbProvider
)
SessionRegenerate
(
oldsid
,
sid
string
)
(
session
.
Store
,
error
)
{
func
(
p
*
SsdbProvider
)
SessionRegenerate
(
oldsid
,
sid
string
)
(
session
.
Store
,
error
)
{
//conn.Do("setx", key, v, ttl)
//conn.Do("setx", key, v, ttl)
if
p
.
client
==
nil
{
if
p
.
client
==
nil
{
...
@@ -123,7 +123,6 @@ func (p *SsdbProvider) SessionDestroy(sid string) error {
...
@@ -123,7 +123,6 @@ func (p *SsdbProvider) SessionDestroy(sid string) error {
}
}
func
(
p
*
SsdbProvider
)
SessionGC
()
{
func
(
p
*
SsdbProvider
)
SessionGC
()
{
return
}
}
func
(
p
*
SsdbProvider
)
SessionAll
()
int
{
func
(
p
*
SsdbProvider
)
SessionAll
()
int
{
...
...
staticfile.go
View file @
3b29a9c1
...
@@ -90,8 +90,6 @@ func serverStaticRouter(ctx *context.Context) {
...
@@ -90,8 +90,6 @@ func serverStaticRouter(ctx *context.Context) {
}
}
http
.
ServeContent
(
ctx
.
ResponseWriter
,
ctx
.
Request
,
filePath
,
sch
.
modTime
,
sch
)
http
.
ServeContent
(
ctx
.
ResponseWriter
,
ctx
.
Request
,
filePath
,
sch
.
modTime
,
sch
)
return
}
}
type
serveContentHolder
struct
{
type
serveContentHolder
struct
{
...
...
utils/utils.go
0 → 100644
View file @
3b29a9c1
package
utils
import
(
"os"
"path/filepath"
"runtime"
"strings"
)
// GetGOPATHs returns all paths in GOPATH variable.
func
GetGOPATHs
()
[]
string
{
gopath
:=
os
.
Getenv
(
"GOPATH"
)
if
gopath
==
""
&&
strings
.
Compare
(
runtime
.
Version
(),
"go1.8"
)
>=
0
{
gopath
=
defaultGOPATH
()
}
return
filepath
.
SplitList
(
gopath
)
}
func
defaultGOPATH
()
string
{
env
:=
"HOME"
if
runtime
.
GOOS
==
"windows"
{
env
=
"USERPROFILE"
}
else
if
runtime
.
GOOS
==
"plan9"
{
env
=
"home"
}
if
home
:=
os
.
Getenv
(
env
);
home
!=
""
{
return
filepath
.
Join
(
home
,
"go"
)
}
return
""
}
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