module Bouncer
  class App
    def initialize
      @renderer = StatusRenderer.new
    end

    def call(env)
      context = RequestContext.new(CanonicalizedRequest.new(env))

      outcome = if context.host.nil? && context.request.path == "/healthcheck"
                  Outcome::Healthcheck
                elsif context.host.nil?
                  Outcome::UnrecognisedHost
                elsif ["/404", "/410"].include?(context.request.path)
                  Outcome::TestThe4xxPages
                elsif context.host.hostname == "www.direct.gov.uk" && context.request.path == "/__canary__"
                  Outcome::Canary
                elsif context.request.path == "/sitemap.xml"
                  Outcome::Sitemap
                elsif context.request.path == "/robots.txt"
                  Outcome::Robots
                elsif context.site.global_type
                  Outcome::GlobalType
                elsif context.request.path == "" # after c14n, '' is equivalent to '/'
                  Outcome::Homepage
                else
                  Outcome::Status
                end

      outcome.new(context, @renderer).serve
    end
  end
end

module Bouncer
  class App
    def initialize
      @renderer = StatusRenderer.new
    end

    def call(env)
      context = RequestContext.new(CanonicalizedRequest.new(env))

      outcome = if context.request.path == "/healthcheck"
                  Outcome::Healthcheck
                elsif context.host.nil?
                  Outcome::UnrecognisedHost
                elsif ["/404", "/410"].include?(context.request.path)
                  Outcome::TestThe4xxPages
                elsif context.host.hostname == "www.direct.gov.uk" && context.request.path == "/__canary__"
                  Outcome::Canary
                elsif context.request.path == "/sitemap.xml"
                  Outcome::Sitemap
                elsif context.request.path == "/robots.txt"
                  Outcome::Robots
                elsif context.site.global_type
                  Outcome::GlobalType
                elsif context.request.path == "" # after c14n, '' is equivalent to '/'
                  Outcome::Homepage
                else
                  Outcome::Status
                end

      outcome.new(context, @renderer).serve
    end
  end
end

Remove 'context.host.nil?' check for healtcheck endpoint
Remove 'context.host.nil?' check for healtcheck endpoint

We're adding a Smokey test to check the healthcheck endpoint so
that we can enable CD on Bouncer: https://github.com/alphagov/smokey/pull/747

We therefore need the /healthcheck endpoint to be available
regardless of what the host is.

There's no clear reason why this conditional was added around 7
years ago:
https://github.com/alphagov/bouncer/commit/ed6f5102123bf9b2b51e36bc209d6340d7ec016a

Similarly old decisions applied in govuk-puppet have been removed
recently: https://github.com/alphagov/govuk-puppet/pull/10852
