Sha256: 68115aca1ffcd261982b606ecd37790e9a039e5e82b4af97b99bb28063189dec

Contents?: true

Size: 534 Bytes

Versions: 1

Compression:

Stored size: 534 Bytes

Contents

module <%= vendor.classify %>
  class API < Grape::API
    include Grape::Kaminari

    content_type :json, "application/json;charset=UTF-8"
    format :json

    helpers <%= vendor.classify %>::ApiHelpers

    rescue_from ActiveRecord::RecordNotFound do |e|
      error!({ error: "404 Not found." }, 404)
    end

    if Rails.env.production?
      rescue_from :all do |e|
        Rails.logger.error e.message + "\n " + e.backtrace.join("\n ")
        error!({ error: "500 Internal server error." }, 500)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
grape-api-generator-0.1.0 lib/generators/grape/templates/api/api.rb