Sha256: 5c766351930e8c69ff1d46bb375d87aac39241b073eda8b4f9e0cf11c0da6e9b

Contents?: true

Size: 1.78 KB

Versions: 2

Compression:

Stored size: 1.78 KB

Contents

require 'active_support/all'
require 'pundit'

module Locomotive
  module API

    # FIX: reload! will work as expected in production
    module Middlewares; end
    module Entities; end

    def self.to_app
      Rack::Builder.new do
        use Locomotive::API::Middlewares::LocaleMiddleware
        use Locomotive::API::Middlewares::LoggerMiddleware
        use Locomotive::API::Middlewares::ParamsDecoderMiddleware
        run Locomotive::API::Dispatch
      end
    end

    class Dispatch < Grape::API

      helpers Pundit::Authorization
      helpers API::Helpers::AuthenticationHelper
      helpers API::Helpers::ParamsHelper
      helpers API::Helpers::PersistenceHelper
      helpers API::Helpers::PaginationHelper
      helpers API::Helpers::LocalesHelper

      include API::ExceptionRescuers

      content_type :xml, 'application/xml'
      content_type :json, 'application/json'

      format :xml
      format :json

      prefix 'v3'

      mount API::Resources::TokenResource
      mount API::Resources::AccountResource
      mount API::Resources::TranslationResource
      mount API::Resources::VersionResource
      mount API::Resources::ThemeAssetResource
      mount API::Resources::SiteResource
      mount API::Resources::SnippetResource
      mount API::Resources::SectionResource
      mount API::Resources::ContentTypeResource
      mount API::Resources::ContentEntryResource
      mount API::Resources::PageResource
      mount API::Resources::MyAccountResource
      mount API::Resources::MembershipResource
      mount API::Resources::CurrentSiteResource
      mount API::Resources::ContentAssetResource
      mount API::Resources::UrlRedirectionResource

      route :any, '*path' do
        error!({ error: "Unrecognized request path: #{params[:path]}" }, 404)
      end

    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
locomotivecms-4.2.0.alpha2 app/api/locomotive/api.rb
locomotivecms-4.2.0.alpha1 app/api/locomotive/api.rb