如何在 Google App Engine 上请求我的服务?

How to request my services on Google App Engine?

我已经在 Google App Engine 上部署了一个包含 2 个服务的 PHP 应用程序:admin 和 api。

我使用配置文件来路由请求。

我的问题是我无法将请求路由到我的服务。只到默认。

结构如下:

|-- admin
    |-- public
        |-- index.php
    |-- admin.yaml
|-- API
    |-- api
        |-- index.php
    |-- api.yaml
|-- dispatch.yaml
|-- index.php

dispatch.yaml:

dispatch: 
  # Send all api traffic to the API.
  - url: "*/API/api/*"
    service: api

  # Send all admin traffic to the admin.
  - url: "*/admin/public/*"
    service: admin
    
  # Default service serves simple hostname request.
  - url: "*/*"
    service: default

admin/admin.yaml:

runtime: php73
service: admin

handlers:
- url: /admin/public/.*
  script: /admin/public/index.php

API/api.yaml:

runtime: php73
service: api

handlers:
- url: /API/api/.*
  script: /API/api/index.php

index.php: echo "Not found";

admin/public/index.php: echo "Welcome to admin service";

API/api/index.php: echo "Welcome to api service";

当我发送请求时:https://SERVICE_ID-dot-PROJECT_ID.REGION_ID.r.appspot.comhttps://PROJECT_ID.REGION_ID.r.appspot.com 响应是预期的:未找到。

但是当我发送请求时:https://SERVICE_ID-dot-PROJECT_ID.REGION_ID.r.appspot.com/API/api/https://PROJECT_ID.REGION_ID.r.appspot.com/API/api/ 响应是 error code 500 而不是:Welcome to api service.

有什么问题吗?配置 ?请求网址?其他 ?

问题出在 yaml 文件中:

新dispatch.yaml

dispatch: 
  # Send all api traffic to the API.
  - url: "SERVICE_ID-dot-PROJECT_ID.REGION_ID.r.appspot.com"
    service: api

  # Send all admin traffic to the admin.
  - url: "SERVICE_ID-dot-PROJECT_ID.REGION_ID.r.appspot.com"
    service: admin
    
  # Default service serves simple hostname request.
  - url: "PROJECT_ID.REGION_ID.r.appspot.com"
    service: default

新 admin/admin.yaml:

runtime: php73
service: admin

handlers:
- url: /.*
  script: /admin/public/index.php

新API/api.yaml:

runtime: php73
service: api

handlers:
- url: /.*
  script: /API/api/index.php

不再有路由问题。