Created
July 30, 2014 08:19
-
-
Save srfrog/dd47071d401810a37e5d to your computer and use it in GitHub Desktop.
find if a method is defined within an struct saved as interface{}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
v := reflect.ValueOf(self.collection) | |
if m := v.MethodByName("Create"); m.IsValid() { | |
handler := m.Interface().(func(ResponseWriter, *Request)) | |
self.Route("POST", "", handler) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment