Class: Syntropy::JSONAPI

Inherits:
Object
  • Object
show all
Defined in:
lib/syntropy/json_api.rb

Overview

JSONAPI is a controller that implements a JSON API.

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ void

Initializes the controller.

Parameters:

  • env (Hash)

    app environment



13
14
15
# File 'lib/syntropy/json_api.rb', line 13

def initialize(env)
  @env = env
end

Instance Method Details

#call(req) ⇒ void

This method returns an undefined value.

Processes the given request.

Parameters:



21
22
23
24
25
26
27
28
# File 'lib/syntropy/json_api.rb', line 21

def call(req)
  response, status = __invoke__(req)
  req.respond(
    response.to_json,
    ':status'       => status,
    'Content-Type'  => 'application/json'
  )
end