decko-commons/decko

View on GitHub
mod/api_key/lib/card_controller/api_key.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
class CardController
  # add support for passing api key through header using X-API-Key
  module ApiKey
    def authenticators
      return {} unless request

      super.merge api_key: api_key_from_header || params[:api_key]
    end

    def api_key_from_header
      request.headers["X-API-Key"]
    end
  end
end