Instantiates the middleware.

 @param app [Rack app] the Rack application on which this middleware
                       should be layered

 When the path is the configured logout path, renders a logout
 response.

 @param env [Hash] a Rack environment
970279
def call(env)
      result = @app.call(env)

      if result.first == 404 &&
          env['REQUEST_METHOD'] == 'GET' &&
          env['PATH_INFO'] == logout_path(env)
        ::Rack::Response.new('You have been logged out.', 200).finish
      else
        result
      end
    end
1152087
def middleware(configuration, environment)
      builder.use Hanami::CommonLogger, Hanami.logger unless Hanami.logger.nil?
      builder.use Rack::ContentLength

      configuration.middleware.each do |m, args, blk|
        builder.use(m, *args, &blk)
      end

      if configuration.early_hints
        require 'hanami/early_hints'
        builder.use Hanami::EarlyHints
      end

      if middleware = environment.static_assets_middleware # rubocop:disable Lint/AssignmentInCondition
        builder.use middleware
      end

      builder.use Rack::MethodOverride
    end
102928
def call(env)
      begin
        if running? && !path_ignored?(env)
          transaction = start_transaction(env)
        end

        resp = @app.call env
      rescue InternalError
        raise # Don't report ElasticAPM errors
      rescue ::Exception => e
        context = ElasticAPM.build_context(rack_env: env, for_type: :error)
        ElasticAPM.report(e, context: context, handled: false)
        raise
      ensure
        if resp && transaction
          status, headers, _body = resp
          transaction.add_response(status, headers: headers.dup)
        end

        ElasticAPM.end_transaction http_result(status)
      end

      resp
    end
372898
def init_app(self, app):
        

        self.__app = app
        self.__app.before_first_request(self.__setup)

        self.tracer.enabled = self.__app.config.get('TRACE_ENABLED', self.tracer.enabled)
1045377
def init_app(self, app, decorators=None):
        
        self.decorators = decorators or self.decorators
        self.app = app

        self.load_config(app)
        # self.load_apispec(app)
        if self.template_file is not None:
            self.template = self.load_swagger_file(self.template_file)
        self.register_views(app)
        self.add_headers(app)

        if self.parse:
            if RequestParser is None:
                raise RuntimeError('Please install flask_restful')
            self.parsers = {}
            self.schemas = {}
            self.format_checker = jsonschema.FormatChecker()
            self.parse_request(app)

        self._configured = True
        app.swag = self
39243
def init_app(self, app):
        
        self.__init__(aws_access_key_id=app.config.get("SES_AWS_ACCESS_KEY"),
                      aws_secret_access_key=app.config.get("SES_AWS_SECRET_KEY"),
                      region=app.config.get("SES_REGION", "us-east-1"),
                      sender=app.config.get("SES_SENDER", None),
                      reply_to=app.config.get("SES_REPLY_TO", None),
                      template=app.config.get("SES_TEMPLATE", None),
                      template_context=app.config.get("SES_TEMPLATE_CONTEXT", {})
        )
43554
def init_app(self, app):
        
        app.config.setdefault('OPENERP_SERVER', 'http://localhost:8069')
        app.config.setdefault('OPENERP_DATABASE', 'openerp')
        app.config.setdefault('OPENERP_DEFAULT_USER', 'admin')
        app.config.setdefault('OPENERP_DEFAULT_PASSWORD', 'admin')

        app.jinja_env.globals.update(
            get_data_from_record=get_data_from_record
        )

        cnx = Client(
            server=app.config['OPENERP_SERVER'],
            db=app.config['OPENERP_DATABASE'],
            user=app.config['OPENERP_DEFAULT_USER'],
            password=app.config['OPENERP_DEFAULT_PASSWORD']
        )

        self.default_user = cnx.user

        app.before_request(self.before_request)
1008792
def apply_to_request(context, rack_env:, for_type:)
      req = rails_req?(rack_env) ? rack_env : Rack::Request.new(rack_env)

      context.request = Context::Request.new unless context.request
      request = context.request

      request.socket = Context::Request::Socket.new(req)
      request.http_version = build_http_version rack_env
      request.method = req.request_method
      request.url = Context::Request::Url.new(req)

      request.body = should_capture_body?(for_type) ? get_body(req) : SKIPPED

      headers, env = get_headers_and_env(rack_env)
      request.headers = headers if config.capture_headers?
      request.env = env if config.capture_env?

      context
    end
1300586
def before_init_app(self, app: FlaskUnchained):
        
        from .templates import (UnchainedJinjaEnvironment,
                                UnchainedJinjaLoader)
        app.jinja_environment = UnchainedJinjaEnvironment
        app.jinja_options = {**app.jinja_options,
                             'loader': UnchainedJinjaLoader(app)}
        app.jinja_env.globals['url_for'] = url_for

        for name in ['string', 'str']:
            app.url_map.converters[name] = StringConverter
1324167
def init_app(self, app):
        
        # Save this so we can use it later in the extension
        if not hasattr(app, 'extensions'):   # pragma: no cover
            app.extensions = {}
        app.extensions['flask-jwt-extended'] = self

        # Set all the default configurations for this extension
        self._set_default_configuration_options(app)
        self._set_error_handler_callbacks(app)
316822
def init_app(self, app, entry_point_group='invenio_oauth2server.scopes',
                 **kwargs):
        
        self.init_config(app)

        state = _OAuth2ServerState(app, entry_point_group=entry_point_group)

        app.extensions['invenio-oauth2server'] = state
        return state
290492
protected function setEnvironment(Application $app, ?string $env = null): void
    {
        $app->detectEnvironment(function () use ($env) {
            return $env ?: env('APP_ENV', 'production');
        });
    }
156940
function(opt) {

        if ( !Config.initialized) {
            var env = opt.env;

            self.startingApp = opt.startingApp;
            self.executionPath = opt.executionPath;

            self.task = opt.task || 'run'; // to be aible to filter later on non run task

            self.userConf = false;
            var path = _(self.executionPath + '/env.json');

            if ( fs.existsSync(path) ) {

                self.userConf = require(path);
                console.debug('Application config file loaded ['
                    + _(self.executionPath + '/env.json') + ']');
            }

            self.Env.parent = self;
            if (env != 'undefined') self.Env.set(env);

            self.Host.parent = self;

            //Do some checking please.. like already has a PID ?.
            //if yes, join in case of standalone.. or create a new thread.
            self.Host.setMaster(opt.startingApp);

            getConf()
        } else {
            if (!opt) {
                return Config.instance
            } else {
                return self.getInstance(opt.startingApp)
            }
        }
    }
106158
function Bootstrap_init(appPath, envFileName) {

        var file,
            env,
            logger,
            server,
            envPath,
            Request,
            filePath;

        if (this.initalized) {
            throw new error.Exception('You cannot reinitialize application');
        }
        // initialize app
        this.initalized = true;

        di.setAlias('appPath', di.getAlias('basePath') + '/' + appPath + '/');
        // set paths
        envPath = di.getAlias('appPath');

        if (Type.isString(envFileName) && ENV_END_PATTERN.test(envFileName)) {
            filePath = envPath + envFileName;
        } else {
            filePath = envPath + "env.json";
        }

        envPath = di.dirname(filePath);
        // set env path
        di.setAlias('envPath', envPath);

        // load config
        try {
            file = fs.readFileSync(filePath, {encoding: 'utf8'});
        } catch (e) {
            throw new error.DataError({filePath: filePath}, 'Problem with loading file, do you have your environment file json in path: "' + envPath + '" ?', e);
        }
        try {
            env = JSON.parse(file);
        } catch (e) {
            throw new error.DataError({file: file}, 'Problem with parsing environment json file', e);
        }

        if (Type.isNumber(env.port)) {
            this.setListenPort(env.port);
        }
        if (Type.isString(env.host)) {
            this.setListenHost(env.host);
        }
        if (Type.isBoolean(env.compression) && env.compression === true) {
            this.enableCompression();
        }
        // set aliases
        if (Type.isArray(env.aliases)) {
            env.aliases.forEach(function setAlias(item) {
                if (Type.isString(item.key) && Type.isString(item.value)) {
                    di.setAlias(item.key, item.value);
                }
            });
        }
        // if there is no controllers path
        if (!di.hasAlias('controllersPath')) {
            di.setAlias('controllersPath', this.controllersPath);
        } else {
            this.controllersPath = di.getAlias('controllersPath');
        }
        // if there is no modules path
        if (!di.hasAlias('modulesPath')) {
            di.setAlias('modulesPath', this.modulesPath);
        } else {
            this.modulesPath = di.getAlias('modulesPath');
        }
        // if there is no models path
        if (!di.hasAlias('modelsPath')) {
            di.setAlias('modelsPath', this.modelsPath);
        } else {
            this.modelsPath = di.getAlias('modelsPath');
        }


        // assets path
        if (Type.isString(env.assetsPath)) {
            this.setAssetsPath(env.assetsPath);
        }
        // initialize list of components over env
        if (Type.isArray(env.components)) {
            component.init(env.components);
        }
        // load config
        if (Type.isString(env.config)) {
            try {
                di.load(envPath + '/' + env.config)(component, di, this);
            } catch (e) {
                throw new error.Exception('Initialize config: ' + envPath + '/' + env.config, e);
            }
        } else {
            throw new error.DataError(env.config, 'Config file is not defined');
        }
        // if there is no logger init logger
        if (!component.has('core/logger')) {
            logger = component.set('core/logger', {});
        } else {
            logger = component.get('core/logger');
        }
        // add memory cache
        if (!component.has('storage/memory')) {
            component.set('storage/memory', {});
        }
        // register router
        if (!component.has('core/router')) {
            component.set('core/router', {});
        }
        // register hooks
        if (!component.has('hooks/request')) {
            component.set('hooks/request', {});
        }
        // set view component
        if (!component.has('core/view')) {
            component.set('core/view', {});
        }
        // http
        if (!component.has('core/http')) {
            component.set('core/http', {});
        }
        // get core http service
        server = component.get('core/http');
        // server listen:
        // add response to api
        // create server
        Request = di.load('core/request');
        server.on('request', function (request, response) {
            logger.info('Bootstrap.init.request: request', request.url);

            // set paths on each request
            di.setAlias('controllersPath', this.controllersPath);
            di.setAlias('modulesPath', this.modulesPath);
            di.setAlias('modelsPath', this.modelsPath);

            // new request
            var nRequest = new Request({
                request: request,
                response: response,
                isCompressionEnabled: this.isCompressionEnabled
            }, request.url);
            /// parse request
            nRequest.parse();

        }.bind(this));

        // this must be last !
        if (!!this.listenHost) {
            server.listen(this.listenPort, this.listenHost);
        } else {
            server.listen(this.listenPort);
        }

        // logger
        logger.info('Bootstrap.init.env', env);
        logger.info('Bootstrap.init.args', this.__dynamic__);

    }
636240
function(app, args) {
  app.set(Constants.RESERVED.ENV, args.env || process.env.NODE_ENV || Constants.RESERVED.ENV_DEV, true);
}
484262
def call(env)
			@app.call(env) if @app.respond_to? :call
			Flame::Dispatcher.new(self.class, env).run!
		end
360156
def _call( env )
      env.merge! "rack.lodash" => {"organisation" => @organisation}

      request = Rack::Request.new(env.dup)
      if request.path_info == @http_path_to_lodash
        response = Rack::Response.new
        # for caching
        response.headers.merge! caching_headers( LODASH_FILE_NAME, LODASH_VERSION_DATE)

        # There's no need to test if the IF_MODIFIED_SINCE against the release date because the header will only be passed if the file was previously accessed by the requester, and the file is never updated. If it is updated then it is accessed by a different path.
        if request.env['HTTP_IF_MODIFIED_SINCE']
          response.status = 304
        else
          response.status = 200
          response.write ::File.read( ::File.expand_path "../../../vendor/assets/javascript/libs/lodash/#{LODASH_VERSION}/lodash.min.js", __FILE__)
        end
        response.finish
      else
        @app.call(env)
      end
    end