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

REST style URLs with HTTP Client #741

Closed
stampy88 opened this issue Jul 31, 2018 · 2 comments
Closed

REST style URLs with HTTP Client #741

stampy88 opened this issue Jul 31, 2018 · 2 comments

Comments

@stampy88
Copy link

I am trying to use the HTTP transport Client to consume an existing web service. The problem is that the URLs are REST style, i.e. they are parameterized based on what you are retrieving. An example would be /api/bar/{id} where the variable id would be filled in at request time.

The problem is that the httptransport.NewClient function requires the URL be known at creation time. So my question is what is the go-kit way of handling URLs like this? Create a new Client every time? Modify the URL on the http.Request that is passed into the encode function?

Thanks!
Dave

@basvanbeek
Copy link
Member

Yes you'd do the latter. An example of a client doing this can be seen here:

https://github.com/basvanbeek/opencensus-gokit-example/tree/master/clients/device/http

It even works if client uses Go kit service discovery. Example down here shows this with setting the baseURL from the emitted new instance:

https://github.com/basvanbeek/opencensus-gokit-example/blob/master/shared/factory/http.go#L31:6

@stampy88
Copy link
Author

Thanks @basvanbeek

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

No branches or pull requests

2 participants