| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Definition of WSGI application for all modules. | 5 """Definition of WSGI application for all modules. |
| 6 | 6 |
| 7 WSGI apps are actually instantiated in apps.py. | 7 WSGI apps are actually instantiated in apps.py. |
| 8 """ | 8 """ |
| 9 | 9 |
| 10 import endpoints | 10 import endpoints |
| 11 import os | 11 import os |
| 12 import sys | 12 import sys |
| 13 import webapp2 | 13 import webapp2 |
| 14 | 14 |
| 15 BASE_DIR = os.path.dirname(os.path.abspath(__file__)) | 15 BASE_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 16 sys.path.insert(0, os.path.join(BASE_DIR, 'components', 'third_party')) | 16 sys.path.insert(0, os.path.join(BASE_DIR, 'components', 'third_party')) |
| 17 | 17 |
| 18 from components import ereporter2 | 18 from components import ereporter2 |
| 19 from components import utils | 19 from components import utils |
| 20 | 20 |
| 21 import admin | 21 import admin |
| 22 import cas | 22 import cas |
| 23 import cipd |
| 23 | 24 |
| 24 | 25 |
| 25 class MainHandler(webapp2.RequestHandler): | 26 class MainHandler(webapp2.RequestHandler): |
| 26 def get(self): | 27 def get(self): |
| 27 self.redirect('/_ah/api/explorer') | 28 self.redirect('/_ah/api/explorer') |
| 28 | 29 |
| 29 | 30 |
| 30 def create_endpoints_app(): | 31 def create_endpoints_app(): |
| 31 """Returns WSGI app that serves cloud endpoints requests.""" | 32 """Returns WSGI app that serves cloud endpoints requests.""" |
| 32 apis = [ | 33 apis = [ |
| 33 admin.AdminApi, | 34 admin.AdminApi, |
| 34 cas.CASServiceApi, | 35 cas.CASServiceApi, |
| 36 cipd.PackageRepositoryApi, |
| 35 ] | 37 ] |
| 36 return endpoints.api_server(apis, restricted=not utils.is_local_dev_server()) | 38 return endpoints.api_server(apis, restricted=not utils.is_local_dev_server()) |
| 37 | 39 |
| 38 | 40 |
| 39 def create_frontend_app(): | 41 def create_frontend_app(): |
| 40 """Returns WSGI app that serves HTML pages.""" | 42 """Returns WSGI app that serves HTML pages.""" |
| 41 routes = [webapp2.Route(r'/', MainHandler)] | 43 routes = [webapp2.Route(r'/', MainHandler)] |
| 42 return webapp2.WSGIApplication(routes, debug=utils.is_local_dev_server()) | 44 return webapp2.WSGIApplication(routes, debug=utils.is_local_dev_server()) |
| 43 | 45 |
| 44 | 46 |
| 45 def create_backend_app(): | 47 def create_backend_app(): |
| 46 """Returns WSGI app that serves task queue and cron handlers.""" | 48 """Returns WSGI app that serves task queue and cron handlers.""" |
| 47 routes = [] | 49 routes = [] |
| 48 routes.extend(cas.get_backend_routes()) | 50 routes.extend(cas.get_backend_routes()) |
| 49 return webapp2.WSGIApplication(routes, debug=utils.is_local_dev_server()) | 51 return webapp2.WSGIApplication(routes, debug=utils.is_local_dev_server()) |
| 50 | 52 |
| 51 | 53 |
| 52 def initialize(): | 54 def initialize(): |
| 53 """Bootstraps the global state and creates WSGI applications.""" | 55 """Bootstraps the global state and creates WSGI applications.""" |
| 54 ereporter2.register_formatter() | 56 ereporter2.register_formatter() |
| 55 return create_endpoints_app(), create_frontend_app(), create_backend_app() | 57 return create_endpoints_app(), create_frontend_app(), create_backend_app() |
| OLD | NEW |