Also, if there already exists a library that does this kind of magic for
REST APIs, I'd love to hear about it.

On Mon, Mar 20, 2017 at 4:01 PM Tyler Compton <xavi...@gmail.com> wrote:

> I'm trying to create an HTTP request router library that automatically
> decodes parameters in the request URL and passes them as arguments to the
> handler function. It would theoretically make something like this possible:
>
> myRouter.HandleFunc("/getPuppies/{id}", func(w http.ResponseWriter, r *
> http.Request, id string) {
>     // Handle the request
> });
>
> I am aware that you can't get the name of a function's arguments. That's
> okay with me, I can just pass the params in the order they appear. However,
> I do need to be able to check how many arguments a function has and what
> the types of those arguments are, so I can type assert the parameters and
> give sane error messages when the user makes a mistake.
>
> Before you point out that this is a bad idea and that reflection is never
> clear, I am fully aware! I'm doing this to learn about reflection in Go and
> to see if Go can support a workflow something like Java's JAX-RS.
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to