mercredi 1 juillet 2015

How do I get the values of arguments passed inside a func() argument in GO?

I am trying to create middleware inside routes and wondering how one can get the values of arguments passed inside a func() argument.

For example:

func (c appContainer) Get(path string, fn func(rw http.ResponseWriter, req *http.Request)) {

    // HOW DO I GET THE VALUES OF rw AND req PASSED IN fn func()?

    c.providers[ROUTER].(Routable).Get(path, fn)
}

I looked through the reflection docs but it's not clear to me or perhaps there is a simpler way?





Aucun commentaire:

Enregistrer un commentaire