Module: Grape::Hal::Dsl

Included in:
Endpoint
Defined in:
lib/grape/hal/dsl.rb

Instance Method Summary collapse

Instance Method Details

#hal_for(context_path, &block) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/grape/hal/dsl.rb', line 5

def hal_for(context_path, &block)
  content_type :json, 'application/hal+json'

  endpoint = Endpoint.new self, context_path
  endpoint.instance_eval(&block)

  get context_path do
    base_url = env['PATH_INFO']
    content_type 'application/hal+json'
    endpoint.generate_hal base_url
  end
end