2
votes

[After digging into the problem, it seems the issue is not about the routing but about the use of endpoints in modules. New question at GAE Modules and Google Endpoints

I'm migrating an GAE application to modules, and I'm confused about the routing, as some queries are correctly routed, but not all of them.

I have the following dispatch.yaml in my root folder. Note that that api module is using the Google Cloud Enpoints API

application: testapp

dispatch:
  - url: "*/foo/*"
    module: foomodule
  - url: "*/_ah/spi/*"
    module: api
  - url: "testapp.appspot.com/"
    module: default

And then one folder by module name, each with a yaml file, defining the URL patterns with handlers, e.g. /www/www.yaml for my default module

application: testapp
version: alpha
runtime: python27
api_version: 1
threadsafe: true

handlers:
- url: /static
  static_dir: static
- url: /.*
  script: www.app

libraries:
- name: webapp2
  version: latest

Queries such as http://testapp.appspot.com/xxx are correctly redirected to default, /foo/xxx ones are handled by the foomodule, but API requests (/_ah/spi/xxx) are going to the default module with a 404.

However, I can see a 200 OK for /_ah/spi/BackendService.logMessages in the logs of the instance mapped to the api module. This one comes from alpha-dot-api-dot-testapp.appspot.com - while the 404 are from testapp.appspot.com only. (NB: I'd like to make my queries work from testapp.appspot.com)

Is there something I am doing wrong? Also, is there a way to list the configuration currently used on the server to make sure it's correctly deployed?

1
Do you have a - url: /_ah/spi/ handler in your api yaml file? - GAEfan
Yes, I have handlers: - url: /_ah/spi/.* script: myapi.app - apassant
Have you run: appcfg.py update dispatch.yaml www.yaml api.yaml foo.yaml? And, in api.yaml, does it have module: api? Do you have any open instances running on the api module? If so, they have have stale code - kill them and try again. - GAEfan
@GAEfan - yes I have the module reference in api/api.yamp. I've already run appcfg.py update www/www.yaml upload/upload.yaml api/api.yaml ; appcfg.py update_dispatch . But still the same error. Even after killing the instances. Also have the 404 when calling the API from the API console / explorer. - apassant

1 Answers

2
votes

It is tempting to factor out endpoints api into a separate module and use dispatch.yaml to set up routes but with dev_appserver.py you seems like can't do this. Based on the code: https://code.google.com/p/googleappengine/source/browse/trunk/python/google/appengine/tools/devappserver2/dispatcher.py?r=411#704

if (not path.startswith('/_ah/') or
    any(path.startswith(wl) for wl
        in DISPATCH_AH_URL_PATH_PREFIX_WHITELIST)):
  return True
else:
  logging.warning('Skipping dispatch.yaml rules because %s is not a '
                  'dispatchable path.', path)
  return False

any path starting with /_ah/ is not a dispatchable path.