<commit_before>local api_matcher = require "api-umbrella.proxy.middleware.api_matcher"
local error_handler = require "api-umbrella.proxy.error_handler"
local host_normalize = require "api-umbrella.utils.host_normalize"
local redirect_matches_to_https = require "api-umbrella.utils.redirect_matches_to_https"
local utils = require "api-umbrella.proxy.utils"
local wait_for_setup = require "api-umbrella.proxy.wait_for_setup"
local web_app_matcher = require "api-umbrella.proxy.middleware.web_app_matcher"
local website_matcher = require "api-umbrella.proxy.middleware.website_matcher"

local get_packed = utils.get_packed
local ngx_var = ngx.var

wait_for_setup()

-- Cache various "ngx.var" lookups that are repeated throughout the stack,
-- so they don't allocate duplicate memory during the request, and since
-- ngx.var lookups are apparently somewhat expensive.
ngx.ctx.args = ngx_var.args
ngx.ctx.arg_api_key = ngx_var.arg_api_key
if(config["router"]["match_x_forwarded_host"]) then
  ngx.ctx.host = ngx_var.http_x_forwarded_host or ngx_var.http_host or ngx_var.host
else
  ngx.ctx.host = ngx_var.http_host or ngx_var.host
end
ngx.ctx.host_normalized = host_normalize(ngx.ctx.host)
ngx.ctx.http_x_api_key = ngx_var.http_x_api_key
ngx.ctx.port = ngx_var.real_port
ngx.ctx.protocol = ngx_var.real_scheme
ngx.ctx.remote_addr = ngx_var.remote_addr
ngx.ctx.remote_user = ngx_var.remote_user
ngx.ctx.request_method = string.lower(ngx.var.request_method)
ngx.ctx.original_request_uri = ngx_var.request_uri
ngx.ctx.request_uri = ngx.ctx.original_request_uri
ngx.ctx.original_uri = ngx_var.uri
ngx.ctx.uri = ngx.ctx.original_uri

local function route_to_web_app()
  redirect_matches_to_https(config["router"]["web_app_backend_required_https_regex"])
  ngx.var.api_umbrella_proxy_pass = "<PASSWORD>"
end

local function route_to_api(api, url_match)
  ngx.ctx.matched_api = api
  ngx.ctx.matched_api_url_match = url_match<commit_msg>In this file, I include two more nginx server variables for checking the word "token" in the url and the header "X-Auth-Token" in the requests made to the platform. With this change is possible to manage and differentiate if the user made a request using an API_Key or OAuth Token<commit_after>local api_matcher = require "api-umbrella.proxy.middleware.api_matcher"
local error_handler = require "api-umbrella.proxy.error_handler"
local host_normalize = require "api-umbrella.utils.host_normalize"
local redirect_matches_to_https = require "api-umbrella.utils.redirect_matches_to_https"
local utils = require "api-umbrella.proxy.utils"
local wait_for_setup = require "api-umbrella.proxy.wait_for_setup"
local web_app_matcher = require "api-umbrella.proxy.middleware.web_app_matcher"
local website_matcher = require "api-umbrella.proxy.middleware.website_matcher"

local get_packed = utils.get_packed
local ngx_var = ngx.var

wait_for_setup()

-- Cache various "ngx.var" lookups that are repeated throughout the stack,
-- so they don't allocate duplicate memory during the request, and since
-- ngx.var lookups are apparently somewhat expensive.
ngx.ctx.args = ngx_var.args
ngx.ctx.arg_api_key = ngx_var.arg_api_key
ngx.ctx.arg_token = ngx_var.arg_token
if(config["router"]["match_x_forwarded_host"]) then
  ngx.ctx.host = ngx_var.http_x_forwarded_host or ngx_var.http_host or ngx_var.host
else
  ngx.ctx.host = ngx_var.http_host or ngx_var.host
end
ngx.ctx.host_normalized = host_normalize(ngx.ctx.host)
ngx.ctx.http_x_api_key = ngx_var.http_x_api_key
ngx.ctx.http_x_auth_token = ngx_var.http_x_auth_token
ngx.ctx.port = ngx_var.real_port
ngx.ctx.protocol = ngx_var.real_scheme
ngx.ctx.remote_addr = ngx_var.remote_addr
ngx.ctx.remote_user = ngx_var.remote_user
ngx.ctx.request_method = string.lower(ngx.var.request_method)
ngx.ctx.original_request_uri = ngx_var.request_uri
ngx.ctx.request_uri = ngx.ctx.original_request_uri
ngx.ctx.original_uri = ngx_var.uri
ngx.ctx.uri = ngx.ctx.original_uri

local function route_to_web_app()
  redirect_matches_to_https(config["router"]["web_app_backend_required_https_regex"])
  ngx.var.api_umbrella_proxy_pass = "http://api_umbrella_web_app_backend"
end

local function route_to_api(api, url_match)
  ngx.ctx.matched_api = api
  ngx.ctx.matched_api_url_match = url_match
{'fraction_non_alphanumeric': 0.09084473808400188, 'fraction_numerical': 0.0, 'mean_word_length': 6.100502512562814, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1445928', 'n_tokens_mistral': 1551, 'n_tokens_neox': 1556, 'n_words': 294}