在Google云终端中提供多个api

时间:2021-08-14 23:12:56

I'm trying to serve 2 different api's with a different set of methods as documented here: https://cloud.google.com/endpoints/docs/deploying-apis-subdomains

我正在尝试使用不同的方法提供2种不同的api,如下所示:https://cloud.google.com/endpoints/docs/deploying-apis-subdomains

via GCE, that are structured as below in my main.py

通过GCE,我的main.py中的结构如下

@endpoints.api(name = 'first', version = 'v1')
class firstApi(remote.Service):
  @endpoints.method(
    # Lots of stuff here
    path = 'first'
    # Lots more here

@endpoints.api(name = 'second', version = 'v1')
class secondApi(remote.Service):
    @endpoints.method(
      # Lots of stuff here
      path = 'second'
      # Lots more here

api = endpoints.api_server([firstApi, secondApi])

but when I generate firstv1openapi.json and secondv1openapi.json and deploy them, something strange happens. When I load it up in Google's API explorer, I see both methods under both API's

但是当我生成firstv1openapi.json和secondv1openapi.json并部署它们时,会发生一些奇怪的事情。当我在Google的API资源管理器中加载它时,我会在两个API下看到这两种方法

What is worse, is when I click on the 2nd API, and try any of the methods via the API explorer, the path always references the 1st API.

更糟糕的是,当我点击第二个API,并通过API资源管理器尝试任何方法时,路径始终引用第一个API。

POST https://my_backend_here.appspot.com/_ah/api/first/v1/second

POST https://my_backend_here.appspot.com/_ah/api/first/v1/second

which as expected fails with a 404.

正如预期的那样失败了404。

I've looked at both firstv1openapi.json and secondv1openapi.json to see if the api's cross reference each other at all, and they both look fine.

我已经查看了firstv1openapi.json和secondv1openapi.json,看看api的交叉引用是否完全相同,它们看起来都很好。

I'm out of trying different options, any help will be much appreciated.

我没有尝试不同的选择,任何帮助将不胜感激。

1 个解决方案

#1


0  

I see that you're using the Python Endpoints Framework. The Framework currently works only in App Engine's Standard environment, not in GCE.

我看到你正在使用Python端点框架。框架目前仅适用于App Engine的标准环境,而不适用于GCE。

#1


0  

I see that you're using the Python Endpoints Framework. The Framework currently works only in App Engine's Standard environment, not in GCE.

我看到你正在使用Python端点框架。框架目前仅适用于App Engine的标准环境,而不适用于GCE。