Sha256: 00c983f7b40587b9d0242c194054a71e8cf90581a57297d90a9a6f5a5b655446
Contents?: true
Size: 636 Bytes
Versions: 6
Compression:
Stored size: 636 Bytes
Contents
module InfinumJsonApiSetup module JsonApi module ContentNegotiation extend ActiveSupport::Concern included do before_action :validate_jsonapi_request end def validate_jsonapi_request if !acceptable? head :not_acceptable elsif !valid_content_type? head :unsupported_media_type end end def valid_content_type? return true if request.body.size.zero? request.content_type == Mime.fetch(:json_api) end def acceptable? request.accept&.split(',')&.include?(Mime.fetch(:json_api)) end end end end
Version data entries
6 entries across 6 versions & 1 rubygems