require 'travis/api/app'

class Travis::Api::App
  class Endpoint
    # Logs are generated by builds.
    class Logs < Endpoint
      # Fetches a log by its *id*.
      get '/:id' do |id|
        result = service(:find_log, params).run
        if result && params[:cors_hax] && result.archived? && result.respond_to?(:archived_url)
          redirect result.archived_url, 307
        else
          respond_with result
        end
      end
    end
  end
end

require 'travis/api/app'

class Travis::Api::App
  class Endpoint
    # Logs are generated by builds.
    class Logs < Endpoint
      # Fetches a log by its *id*.
      get '/:id' do |id|
        result = service(:find_log, params).run
        halt 404 if result.nil?

        if params[:cors_hax] && result.archived? && result.respond_to?(:archived_url)
          redirect result.archived_url, 307
        else
          respond_with result
        end
      end
    end
  end
end

Halt early if no log is found
Halt early if no log is found
