Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
张磊
/
FileStorageBeego
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
af4f1538
authored
2014-06-21 11:44:24 +0800
by
astaxie
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
beego: update the router rule for *
* not match the empty route
1 parent
469f283b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
4 additions
and
7 deletions
beego.go
router.go
tree.go
tree_test.go
beego.go
View file @
af4f153
...
...
@@ -381,9 +381,11 @@ func initBeforeHttpRun() {
middleware
.
RegisterErrorHandler
()
for
u
,
_
:=
range
StaticDir
{
Get
(
u
,
serverStaticRouter
)
Get
(
u
+
"/*"
,
serverStaticRouter
)
}
if
EnableDocs
{
Get
(
"/docs"
,
serverDocs
)
Get
(
"/docs/*"
,
serverDocs
)
}
}
...
...
router.go
View file @
af4f153
...
...
@@ -350,9 +350,11 @@ func (p *ControllerRegistor) AddAutoPrefix(prefix string, c ControllerInterface)
route
.
methods
=
map
[
string
]
string
{
"*"
:
rt
.
Method
(
i
)
.
Name
}
route
.
controllerType
=
ct
pattern
:=
path
.
Join
(
prefix
,
controllerName
,
strings
.
ToLower
(
rt
.
Method
(
i
)
.
Name
),
"*"
)
patternfix
:=
path
.
Join
(
prefix
,
controllerName
,
strings
.
ToLower
(
rt
.
Method
(
i
)
.
Name
))
route
.
pattern
=
pattern
for
_
,
m
:=
range
HTTPMETHOD
{
p
.
addToRouter
(
m
,
pattern
,
route
)
p
.
addToRouter
(
m
,
patternfix
,
route
)
}
}
}
...
...
tree.go
View file @
af4f153
...
...
@@ -267,12 +267,6 @@ func (leaf *leafInfo) match(wildcardValues []string) (ok bool, params map[string
}
return
true
,
params
}
if
len
(
leaf
.
wildcards
)
==
1
&&
leaf
.
wildcards
[
0
]
==
":splat"
{
params
=
make
(
map
[
string
]
string
)
params
[
":splat"
]
=
""
return
true
,
params
}
Error
(
"bug of router"
)
return
false
,
nil
}
else
if
len
(
wildcardValues
)
==
0
{
// static path
return
true
,
nil
...
...
tree_test.go
View file @
af4f153
...
...
@@ -18,7 +18,6 @@ func init() {
routers
=
append
(
routers
,
testinfo
{
"/customer/login"
,
"/customer/login"
,
nil
})
routers
=
append
(
routers
,
testinfo
{
"/customer/login"
,
"/customer/login.json"
,
map
[
string
]
string
{
":ext"
:
"json"
}})
routers
=
append
(
routers
,
testinfo
{
"/*"
,
"/customer/123"
,
map
[
string
]
string
{
":splat"
:
"customer/123"
}})
routers
=
append
(
routers
,
testinfo
{
"/customer/*"
,
"/customer"
,
map
[
string
]
string
{
":splat"
:
""
}})
routers
=
append
(
routers
,
testinfo
{
"/*"
,
"/customer/2009/12/11"
,
map
[
string
]
string
{
":splat"
:
"customer/2009/12/11"
}})
routers
=
append
(
routers
,
testinfo
{
"/*.*"
,
"/nice/api.json"
,
map
[
string
]
string
{
":path"
:
"nice/api"
,
":ext"
:
"json"
}})
routers
=
append
(
routers
,
testinfo
{
"/:name/*.*"
,
"/nice/api.json"
,
map
[
string
]
string
{
":name"
:
"nice"
,
":path"
:
"api"
,
":ext"
:
"json"
}})
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
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 post a comment