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
3d481178
authored
2013-08-04 23:06:48 +0800
by
astaxie
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
improve router
1 parent
d0cb112f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
8 deletions
router.go
router.go
View file @
3d48117
...
...
@@ -383,13 +383,12 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
findrouter
=
true
break
}
if
(
requestPath
[
n
-
1
]
!=
'/'
&&
route
.
pattern
==
requestPath
)
||
(
requestPath
[
n
-
1
]
==
'/'
&&
len
(
route
.
pattern
)
>=
n
-
1
&&
requestPath
[
0
:
n
-
1
]
==
route
.
pattern
)
||
(
len
(
route
.
pattern
)
==
n
+
1
&&
requestPath
==
route
.
pattern
[
0
:
n
])
{
runrouter
=
route
findrouter
=
true
break
// pattern /admin url /admin 200 /admin/ 404
// pattern /admin/ url /admin 301 /admin/ 200
if
requestPath
[
n
-
1
]
!=
'/'
&&
len
(
route
.
pattern
)
==
n
+
1
&&
route
.
pattern
[
n
]
==
'/'
&&
route
.
pattern
[
:
n
-
1
]
==
requestPath
{
http
.
Redirect
(
w
,
r
,
requestPath
+
"/"
,
301
)
return
}
}
...
...
@@ -545,7 +544,10 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
if
!
findrouter
{
for
cName
,
methodmap
:=
range
p
.
autoRouter
{
if
strings
.
HasPrefix
(
strings
.
ToLower
(
requestPath
),
"/"
+
cName
)
{
if
strings
.
ToLower
(
requestPath
)
==
"/"
+
cName
+
"/"
{
requestPath
=
requestPath
+
"index"
}
if
strings
.
HasPrefix
(
strings
.
ToLower
(
requestPath
),
"/"
+
cName
+
"/"
)
{
for
mName
,
controllerType
:=
range
methodmap
{
if
strings
.
HasPrefix
(
strings
.
ToLower
(
requestPath
),
"/"
+
cName
+
"/"
+
strings
.
ToLower
(
mName
))
{
//parse params
...
...
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