Comments (5)
So I've been thinking that we could add the following attributes to allow most flexibility while keeping the defaults simple:
local
/ boolean / default false
localHost
/ string / default 'localhost'
localPort
/ int / default 8080
With local
set, http://{{localHost}}:{{localPort}}/_ah/api
would be used with the defaults used as in the app engine default configuration. The appId
parameter would be ignored in this case.
Default values could be overwritten using localHost and localPort, e.g. if you are running your dev server on a different machine.
In the simplest case you would then have
Dev env: <google-api-loader api="myApi" version="v1" local></google-api-loader>
Deployed: <google-api-loader api="myApi" version="v1" appId="myAppId"></google-api-loader>
Developers could also use a conditional attribute for local
, to simply switch between dev and deployed environment, but that's up to them how to implement this:
<google-api-loader api="myApi" version="v1" appId="myAppId" local?="{{dev}}"></google-api-loader>
@ebidel, thoughts? I could PR those changes if they sound okay to you.
from google-apis.
I think we need a new element for the cloud stuff for two reasons:
- these additional params won't make sense for the majority of the API
- we should exercise the extensibility and reusability of components :)
` (or something similar).
For the specific param name, I like what the app engine dev_server does with --host and --port
. We could do:
<google-cloud-endpoints-api appId="myAppId" host="localhost" port="8080"></google-cloud-endpoints-api>
If host or port are given, they override appId to form the URL.
An alternative (but more work) would be to create a mock element for testing. Scott through this POC together for core-ajax: https://github.com/PolymerLabs/mock-ajax
from google-apis.
mock-ajax sounds great but I think it has a different purpose. You'd still want to be able to load a custom API from dev server to run a local copy of the app, as well as maybe run automated tests with mock-ajax. But it's different, unless I'm missing something.
Why not just change appId
attribute to root
? That way the loader would support both dev and production/deployed:
Dev:
<google-api-loader name="myApi" version="v1" root="http://localhost:8080/_ah/api">
Prod:
<google-api-loader name="myApi" version="v1" root="https://myapp.appspot.com/_ah/api">
statuses_[this.name] = 'loading';
loaders_[this.name] = this;
gapi.client.load(this.name, this.version,
this.handleLoadResponse.bind(this), this.root);
from google-apis.
Can't use this element with polymer starter kit and local development endpont cause new root property overlaps with some #document-fragment and can't be set. I think it should be renamed to somethong other than root, apiroot for example.
from google-apis.
Hah, I just encountered a similar problem and created a new issue here: #49
:)
from google-apis.
Related Issues (20)
- How to use the geocoding service by using google-maps-api? HOT 6
- [Feature request] Boolean to state if google-client-loader has finished loading HOT 3
- Load all Maps API libraries by default (proposal) HOT 2
- Unexpected token ILLEGAL in google-maps-api.html HOT 2
- Trouble using custom API endpoints HOT 2
- Do we need google-apis set to experimental by default? HOT 5
- Refresh Access tokens automatically.
- Possible to use Contacts API with google-client-loader HOT 1
- Google Maps API multiple times error with Angular 2 HOT 21
- Cannot load Google Maps API libraries HOT 3
- Add support to use goole-apis element in a dynamic SPA
- Element should not use a dom-module HOT 1
- Improve documentation of Google-apis oauth flow
- Race condition on google-client-loader HOT 9
- WebComponent conflicting with previously loaded maps HOT 3
- Add region to google-maps-api
- Polymer 2.0 HOT 2
- Polymer 3.0 HOT 1
- intended purpose of google-maps-api? HOT 1
- [Feature Request] api-key property for google-client-loader
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from google-apis.