应用引擎 javascript 客户端的服务器命名空间
server namespace for app-engine javascript client
通常我的端点有一个 android/iOS 客户端。我现在正在尝试与 javascript 客户合作。查看提供的 git example,我看到许多名称空间内容(第 9-19 行)。为什么这些很重要?假设我的 api 存在于 my-endpoints.appspot.com
,我必须做命名空间的事情吗?怎么样?
另外,是否有人不介意分享更全面的示例?更充分地锻炼全客户的东西 api https://developers.google.com/api-client-library/javascript/reference/referencedocs
'namespace thing' is not necessary. You should be free write in the style that you like by loading your code as they do in the example and making a no-argument initialiser that calls your code, which is passed to the API client here. It seems that a gapi
global is initialised after the google api client is loaded but before your code is run. This allows your endpoint to be accessed.
Romin Irani 的教程就是一个很好的例子:https://rominirani.com/google-cloud-endpoints-tutorial-part-4-37ea3aac7948
但是请注意,Google 最近建议为 JavaScript 使用 Google API 客户端库的承诺模式。参见 https://developers.google.com/api-client-library/javascript/features/promises#using-promises and
通常我的端点有一个 android/iOS 客户端。我现在正在尝试与 javascript 客户合作。查看提供的 git example,我看到许多名称空间内容(第 9-19 行)。为什么这些很重要?假设我的 api 存在于 my-endpoints.appspot.com
,我必须做命名空间的事情吗?怎么样?
另外,是否有人不介意分享更全面的示例?更充分地锻炼全客户的东西 api https://developers.google.com/api-client-library/javascript/reference/referencedocs
'namespace thing' is not necessary. You should be free write in the style that you like by loading your code as they do in the example and making a no-argument initialiser that calls your code, which is passed to the API client here. It seems that a gapi
global is initialised after the google api client is loaded but before your code is run. This allows your endpoint to be accessed.
Romin Irani 的教程就是一个很好的例子:https://rominirani.com/google-cloud-endpoints-tutorial-part-4-37ea3aac7948
但是请注意,Google 最近建议为 JavaScript 使用 Google API 客户端库的承诺模式。参见 https://developers.google.com/api-client-library/javascript/features/promises#using-promises and