Class: Grape::App::Configuration

Inherits:
ActiveSupport::InheritableOptions
  • Object
show all
Defined in:
lib/grape/app/configuration.rb

Instance Method Summary collapse

Instance Method Details

#cors(&block) ⇒ Object



8
9
10
11
# File 'lib/grape/app/configuration.rb', line 8

def cors(&block)
  self.cors = block if block
  super
end

#cors_allow_origins=(value) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/grape/app/configuration.rb', line 13

def cors_allow_origins=(value)
  warn "[DEPRECATION] setting `config.cors_allow_origins` is deprecated. Please use `config.cors` with a block instead. [#{caller(1..1).first}]"

  value = Array.wrap(value)
  cors do
    allow do
      origins *value # rubocop:disable Lint/AmbiguousOperator
      resource '*', headers: :any, methods: %i[get post options delete put]
    end
  end
end

#middleware(&block) ⇒ Object



2
3
4
5
6
# File 'lib/grape/app/configuration.rb', line 2

def middleware(&block)
  self[:middleware] ||= []
  self[:middleware].push(block) if block
  super
end