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
00b710e1
authored
2014-06-11 23:51:19 +0800
by
astaxie
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
beego:namespace sub router add url to pattern
1 parent
e25fcffb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
0 deletions
namespace.go
namespace.go
View file @
00b710e
...
...
@@ -198,10 +198,12 @@ func (n *Namespace) Namespace(ns ...*Namespace) *Namespace {
for
_
,
ni
:=
range
ns
{
for
k
,
v
:=
range
ni
.
handlers
.
routers
{
if
t
,
ok
:=
n
.
handlers
.
routers
[
k
];
ok
{
addPrefix
(
v
,
ni
.
prefix
)
n
.
handlers
.
routers
[
k
]
.
AddTree
(
ni
.
prefix
,
v
)
}
else
{
t
=
NewTree
()
t
.
AddTree
(
ni
.
prefix
,
v
)
addPrefix
(
t
,
ni
.
prefix
)
n
.
handlers
.
routers
[
k
]
=
t
}
}
...
...
@@ -225,10 +227,12 @@ func AddNamespace(nl ...*Namespace) {
for
_
,
n
:=
range
nl
{
for
k
,
v
:=
range
n
.
handlers
.
routers
{
if
t
,
ok
:=
BeeApp
.
Handlers
.
routers
[
k
];
ok
{
addPrefix
(
v
,
n
.
prefix
)
BeeApp
.
Handlers
.
routers
[
k
]
.
AddTree
(
n
.
prefix
,
v
)
}
else
{
t
=
NewTree
()
t
.
AddTree
(
n
.
prefix
,
v
)
addPrefix
(
t
,
n
.
prefix
)
BeeApp
.
Handlers
.
routers
[
k
]
=
t
}
}
...
...
@@ -245,6 +249,20 @@ func AddNamespace(nl ...*Namespace) {
}
}
func
addPrefix
(
t
*
Tree
,
prefix
string
)
{
for
_
,
v
:=
range
t
.
fixrouters
{
addPrefix
(
v
,
prefix
)
}
if
t
.
wildcard
!=
nil
{
addPrefix
(
t
.
wildcard
,
prefix
)
}
if
t
.
leaf
!=
nil
{
if
c
,
ok
:=
t
.
leaf
.
runObject
.
(
*
controllerInfo
);
ok
{
c
.
pattern
=
prefix
+
c
.
pattern
}
}
}
// Namespace Condition
func
NSCond
(
cond
namespaceCond
)
innnerNamespace
{
return
func
(
ns
*
Namespace
)
{
...
...
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