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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

only prepend `http://` to endpoint if no protocol was provided #191

Merged
merged 2 commits into from Oct 13, 2017

Conversation

Projects
None yet
2 participants
@Crunch09
Contributor

Crunch09 commented Oct 10, 2017

Hey,
this addresses the fix mentioned in #174: Although the Toxiproxy HTTP API does not support HTTPS, it should not prepend http:// to the endpoint.

client.NewClient("https://example.com")
// Before: http://https//example.com
// After: https://example.com

I would love to write a test for this but endpoint is not an exported identifier so i'm not sure how to test this as this is basically the first Go code that i have ever written 馃檪

fixes #174

@jpittis

This is an improvement over the current code. Thanks for opening a PR!

Because Toxiproxy does not support HTTPS, it might be nice to fail fast with a clear error message when an https: protocol is provided.

IMO it would be appropriate to fail with a log.Fatal("the toxiproxy client does not support https") if an HTTPS protocol is provided.

Show outdated Hide outdated client/client.go
@Crunch09

This comment has been minimized.

Show comment
Hide comment
@Crunch09

Crunch09 Oct 12, 2017

Contributor

@jpittis Thank you for the review! 馃憤 I updated the code to now fail when https:// is provided and removed the regexp again because i felt it didn't add much value then but thank you for letting me know about MustCompile! 馃挴

Before:
bildschirmfoto 2017-10-12 um 23 17 07

After:
bildschirmfoto 2017-10-12 um 23 17 14

Contributor

Crunch09 commented Oct 12, 2017

@jpittis Thank you for the review! 馃憤 I updated the code to now fail when https:// is provided and removed the regexp again because i felt it didn't add much value then but thank you for letting me know about MustCompile! 馃挴

Before:
bildschirmfoto 2017-10-12 um 23 17 07

After:
bildschirmfoto 2017-10-12 um 23 17 14

@jpittis jpittis merged commit 87f5ccc into Shopify:master Oct 13, 2017

@jpittis

This comment has been minimized.

Show comment
Hide comment
@jpittis

jpittis Oct 13, 2017

Collaborator

Thanks for the contribution! :)

Collaborator

jpittis commented Oct 13, 2017

Thanks for the contribution! :)

@Crunch09 Crunch09 deleted the Crunch09:host_protocol branch Oct 13, 2017

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