Class: ApiController

Inherits:
ApplicationController show all
Defined in:
app/controllers/api_controller.rb

Instance Attribute Summary

Attributes inherited from ApplicationController

#req, #res

Instance Method Summary collapse

Methods inherited from ApplicationController

#boolean_param, #csrf_token, #delete_all_images_from_content, #delete_from_storage, #initialize, #params, #redirect_to, #render, #session, #validate!

Constructor Details

This class inherits a constructor from ApplicationController

Instance Method Details

#halt_error(message, status: 400) ⇒ Object



15
16
17
18
# File 'app/controllers/api_controller.rb', line 15

def halt_error(message, status: 400)
  render_json({ error: message }, status: status)
  throw(:halt)
end

#render_json(data, status: 200) ⇒ Object



5
6
7
8
9
# File 'app/controllers/api_controller.rb', line 5

def render_json(data, status: 200)
  @res.status = status
  @res.headers['Content-Type'] = 'application/json'
  @res.body << data.to_json
end

#statusObject



11
12
13
# File 'app/controllers/api_controller.rb', line 11

def status
  render_json({ status: 'ok', version: '2.0.0', type: FEATURES_CONFIG['type'] })
end