Skip to content

Commit

Permalink
Merge pull request beego#2978 from BorisBorshevsky/fix_reflection_bug
Browse files Browse the repository at this point in the history
fix bug beego#2972
  • Loading branch information
astaxie authored Dec 18, 2017
2 parents bf5c562 + 0e369e6 commit f166888
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions router.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,12 @@ func (p *ControllerRegister) addWithMethodParams(pattern string, c ControllerInt

numOfFields := elemVal.NumField()
for i := 0; i < numOfFields; i++ {
fieldVal := elemVal.Field(i)
fieldType := elemType.Field(i)
execElem.FieldByName(fieldType.Name).Set(fieldVal)

if execElem.FieldByName(fieldType.Name).CanSet() {
fieldVal := elemVal.Field(i)
execElem.FieldByName(fieldType.Name).Set(fieldVal)
}
}

return execController
Expand Down

0 comments on commit f166888

Please sign in to comment.