Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Request.execute public #12

Closed
bmurphy1976 opened this issue Oct 8, 2015 · 4 comments
Closed

Make Request.execute public #12

bmurphy1976 opened this issue Oct 8, 2015 · 4 comments
Assignees

Comments

@bmurphy1976
Copy link

There are cases where we have to programmatically decide which http method to use when invoking an API. While we can create a map of handler functions to call the various put/post/get/delete/options functions on a Request, it would be simpler if we could just pass the desired method to Execute directly, i.e:

resp, err := resty.R().Execute(resty.POST, url)

vs what I have to do right now:

type handler func(*resty.Request, string) (*resty.Response, error)

func get(r *resty.Request, url string) (*resty.Response, error) {
  return r.Get(url)
}

func post(r *resty.Request, url string) (*resty.Response, error) {
  return r.Post(url)
}

handlers := make(map[string]handler)
handlers[resty.GET] = get
handlers[resty.POST] = post
// etc

resp, err := handlers[resty.POST](resty.R(), url)
@jeevatkm jeevatkm self-assigned this Oct 8, 2015
@jeevatkm
Copy link
Member

jeevatkm commented Oct 8, 2015

I agree, it makes sense.

I have just released v0.3; looking at your need, I will bring this changes to master today itself (accessible via github.com/go-resty/resty) however will make a release later on via tag (accessible via gopkg.in/resty.v0).

is it okay?

@jeevatkm
Copy link
Member

jeevatkm commented Oct 8, 2015

Request.Execute method is public now, available in master branch. Will be scheduled for release!

@jeevatkm jeevatkm modified the milestone: v0.4 Milestone Oct 16, 2015
@bmurphy1976
Copy link
Author

Can confirm, works great! Thanks!

@jeevatkm
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants