# Path: zengine/config.py

# 
# Path: zengine/log.py



import json
import falcon
import sys
from zengine.config import settings
from zengine.log import log
# -*-  coding: utf-8 -*-
"""
Middlewares for request / response handling.
"""
# Copyright (C) 2015 ZetaOps Inc.
#
# This file is licensed under the GNU General Public License v3
# (GPLv3).  See LICENSE.txt for details.


class CORS(object):
    """
    Sets required headers to allow origins for the hosts listed in
    :attr:`~zengine.settings.ALLOWED_ORIGINS`

    Note:
        When :attr:`~zengine.settings.DEBUG` set to ``True``
        all hosts are allowed
    """

    def process_response(self, request, response, resource):
        """
        Do response processing
        """
        origin = request.get_header('Origin')
        if not settings.DEBUG:

# Path: zengine/config.py

# 
# Path: zengine/log.py



# Path: zengine/middlewares.py
import json
import falcon
import sys
from zengine.config import settings
from zengine.log import log

# -*-  coding: utf-8 -*-
"""
Middlewares for request / response handling.
"""
# Copyright (C) 2015 ZetaOps Inc.
#
# This file is licensed under the GNU General Public License v3
# (GPLv3).  See LICENSE.txt for details.


class CORS(object):
    """
    Sets required headers to allow origins for the hosts listed in
    :attr:`~zengine.settings.ALLOWED_ORIGINS`

    Note:
        When :attr:`~zengine.settings.DEBUG` set to ``True``
        all hosts are allowed
    """

    def process_response(self, request, response, resource):
        """
        Do response processing
        """
        origin = request.get_header('Origin')
        if not settings.DEBUG:

            if origin in settings.ALLOWED_ORIGINS or not origin: