I currently route any request where the path starts with /app
to a single static file, that does routing using Javascript.
Now, I'd like to support Google's ajax crawling protocol, which means I have to return HTML snapshots at any url that starts with /app
and ends with ?_escaped_fragment=
.
I have these two handlers:
- url: /app\?_escaped_fragment=
script: main.app
- url: /app(/.*)?
static_files: static/pages/app.html
upload: static/pages/app\.html
But requests to /app?_escaped_fragment=
are still routed to the static page. Is there a way to match the query parameters?
I know I can route /app(/.*)?
to a script that returns either the static page, or a snapshot based on the presence of the query parameter, but serving static files is a lot cheaper, so I'd like only requests with the query parameter to hit my app server.
While it would be nice, if you read the spec, the handlers section is for REGEXP matching on paths only, not query params. If you design your app using RESTful principles, you can easily convert your query param access to URI-based access. Just route based on
/app/escaped_fragment/.*
and in the handler function, inspect the rest of the path to find which specific resource of type escaped_fragment is being requested.