Skip to content

Conversation

@bradfriedman
Copy link
Contributor

If the config is being generated locally (using endpointscfg.py), we stick to the old logic of "HTTP if localhost else HTTPS". When it's being generated remotely (using apiserving.py), we use the new logic: "HTTP if running on development server, else HTTPS"

@codecov-io
Copy link

codecov-io commented Oct 17, 2016

Current coverage is 77.90% (diff: 97.72%)

Merging #14 into master will decrease coverage by 0.12%

@@             master        #14   diff @@
==========================================
  Files            35         35          
  Lines          4461       4521    +60   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits           3481       3522    +41   
- Misses          980        999    +19   
  Partials          0          0          

Powered by Codecov. Last update b60151e...175f11a

protocol = ('http' if hostname and hostname.startswith('localhost') else
'https')
else:
protocol = ('http' if endpoints_util.is_running_on_devserver() else
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the local param needed again? Why can't we just say http if on devserver, https otherwise?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understand it, a config can be generated either remotely (via an HTTP call to the service) or locally (using endpointscfg). If it's done locally, then it doesn't make sense to check whether we're running on a dev_appserver or not; it's just being run from a command-line prompt.

Does that make sense?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me that we don't really need to differentiate between the two cases. I feel like it should be possible to eliminate the local parameter and have the logic be:

if devserver or hostname == localhost, return HTTP, else HTTPS

endpointscfg.py supports overriding a hostname so it should be enough to predicate HTTP on those two things.

@bradfriedman
Copy link
Contributor Author

Alright, per our discussion offline, this is quite a bit simpler. :) PTAL

hostname = (hostname or util.get_app_hostname() or
api_info.hostname)
protocol = ('http' if hostname and hostname.startswith('localhost') else
'https')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this also be updated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. I also wrote some new tests for swagger generation to make sure the protocol is showing up correctly in the devserver case there, along with some refactoring for the test. PTAL.

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

Successfully merging this pull request may close these issues.

3 participants