Sha256: fcb9f2c8caf887b0bb2aa4a1a486d2a30d63d1b224cbecc2ffccf292ad3f364c
Contents?: true
Size: 707 Bytes
Versions: 1
Compression:
Stored size: 707 Bytes
Contents
module <%= vendor.classify %> module ApiHelpers extend Grape::API::Helpers params :pagination do optional :page, type: Integer, default: 1 optional :per_page, type: Integer, default: 20 end def current_<%= model_name %> # Implement your API authentication here # @current_<%= model_name %> ||= <%= model_name.classify %>.authenticate!(env) end def authenticate! error!({ error: "401 Unauthorized." }, 401) unless current_<%= model_name %> end def permitted_params declared(params, include_missing: false) end def resource_error!(resource) error!({ error: user.errors.full_messages.join(', ') }, 422) 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_helpers.rb |