1

My app.yaml file has many different url handlers, but there are some properties that must be in every one of them. For instance, a secure: always property. How can I make this a default property and avoid having to manually add this to every handler?

handlers:
- url: /api/.+
  script: backend.api.app
  secure: always

- url: /.*
  static_files: static/pages/build/index.html
  upload: static/pages/build/index.html
  secure: always

I am worried that I will add a url and forget to copy all of my default properties into it.

Note: I use Grunt, so if it is impossible to do this though Google App Engine a solution that parses the YAML file and adds properties could work

Daniel F
  • 340
  • 1
  • 3
  • 16
  • Why the downvote whoever you are? Is there something I could do to ask better questions in the future? – Daniel F Dec 29 '15 at 21:38
  • Downvote makes no sense, hence, upvoting to compensate. – Alex Martelli Dec 29 '15 at 23:14
  • Thank you @Alex Martelli – Daniel F Dec 29 '15 at 23:15
  • Why not use single entry point and manage routes on python side? And SSL for static files does not seems to be so important. – Dmytro Sadovnychyi Dec 30 '15 at 04:39
  • @DmitrySadovnychyi I considered that, but somehow assumed that it would be faster to manage routes in app.yaml than python-side. Am I wrong? Also, I thought that SSL for static files would help prevent an attacker from modifying their content. Is that correct? – Daniel F Dec 30 '15 at 04:48
  • I don't think that you're going to feel the difference in performance. Anyway, if you use something like `grunt` or `gulp` – I'm sure you can write your own solution and share it with public. – Dmytro Sadovnychyi Dec 30 '15 at 04:50
  • @DmitrySadovnychyi You were correct. http://stackoverflow.com/questions/3025921/is-there-a-performance-gain-from-defining-routes-in-app-yaml-versus-one-large-ma – Daniel F Dec 30 '15 at 06:00

1 Answers1

3

No, there are no configurable defaults for handlers other than those mentioned in the documentation.

But you can write a simple script to load your app.yaml file and check that all your handlers have whichever common configurations you desire ;)

Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97
  • Specifically, use PyYAML -- http://pyyaml.org/wiki/PyYAML -- to parse a YAML file into Python data structures in memory, alter those data structures as you require, then use PyYAML again to emit them as YAML -- much like you'd do for other serialization formats such as JSON or XML (with different parser-and-emitter modules in each case of course). – Alex Martelli Dec 29 '15 at 23:17