Sha256: 0a79e0504e31ae3e8ea620748524cddfb0ff69aa359a71460555b2c87526d296

Contents?: true

Size: 806 Bytes

Versions: 4

Compression:

Stored size: 806 Bytes

Contents

module Api::V1::Base
  extend ActiveSupport::Concern

  included do
    include Api::V1::Defaults
    include Api::V1::LoadsAndAuthorizesApiResource

    version "v1"
    use ::WineBouncer::OAuth2

    rescue_from :all do |error|
      handle_api_error(error)
    end

    BulletTrain::Api.endpoints.each do |endpoint_class|
      mount endpoint_class.constantize
    end
  end

  class_methods do
    # TODO I actually don't know of any way to make this work. This was supposed to be run after all other endpoints
    # are registered, but I don't know of a way to know when we're done running `initializer` blocks from the engines
    # a user may have included.
    def handle_not_found
      route :any, "*path" do
        raise StandardError, "Unable to find API endpoint"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bullet_train-api-1.0.12 app/controllers/concerns/api/v1/base.rb
bullet_train-api-1.0.8 app/controllers/concerns/api/v1/base.rb
bullet_train-api-1.0.7 app/controllers/concerns/api/v1/base.rb
bullet_train-api-1.0.6 app/controllers/concerns/api/v1/base.rb