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
7c610ee7
authored
2013-07-25 16:00:42 +0800
by
astaxie
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix reflect find methodByName
1 parent
23deaedd
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
2 deletions
router.go
router.go
View file @
7c610ee
...
...
@@ -94,7 +94,8 @@ func (p *ControllerRegistor) Add(pattern string, c ControllerInterface, mappingM
}
}
}
t
:=
reflect
.
Indirect
(
reflect
.
ValueOf
(
c
))
.
Type
()
reflectVal
:=
reflect
.
Indirect
(
reflect
.
ValueOf
(
c
))
t
:=
reflectVal
.
Type
()
methods
:=
make
(
map
[
string
]
string
)
if
len
(
mappingMethods
)
>
0
{
semi
:=
strings
.
Split
(
mappingMethods
[
0
],
";"
)
...
...
@@ -106,7 +107,7 @@ func (p *ControllerRegistor) Add(pattern string, c ControllerInterface, mappingM
comma
:=
strings
.
Split
(
colon
[
0
],
","
)
for
_
,
m
:=
range
comma
{
if
m
==
"*"
||
inSlice
(
strings
.
ToLower
(
m
),
HTTPMETHOD
)
{
if
_
,
ok
:=
t
.
MethodByName
(
colon
[
1
]);
ok
{
if
val
:=
reflectVal
.
FieldByName
(
colon
[
1
]);
val
.
IsValid
()
{
methods
[
strings
.
ToLower
(
m
)]
=
colon
[
1
]
}
else
{
panic
(
colon
[
1
]
+
" method don't exist in the controller "
+
t
.
Name
())
...
...
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