Module: Angus::BaseActions

Included in:
Base
Defined in:
lib/angus/base_actions.rb

Instance Method Summary collapse

Instance Method Details

#api_pathObject



41
42
43
# File 'lib/angus/base_actions.rb', line 41

def api_path
  "#{base_path}/api/#{service_version}"
end

#discover_pathsObject



4
5
6
7
8
9
# File 'lib/angus/base_actions.rb', line 4

def discover_paths
  {
    'doc' => doc_path,
    'api' => api_path
  }
end

#doc_pathObject



37
38
39
# File 'lib/angus/base_actions.rb', line 37

def doc_path
  "#{base_path}/doc/#{service_version}"
end

#register_base_routesObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/angus/base_actions.rb', line 11

def register_base_routes
  router.on(:get, '/') do |env, params|
    response = Response.new

    render(response, discover_paths)
  end

  router.on(:get, base_path) do |env, params|
    response = Response.new

    render(response, discover_paths)
  end

  router.on(:get, doc_path) do |env, params|
    response = Response.new

    if params[:format] == 'json'
      render(response, Angus::SDoc::JsonFormatter.format_service(@definitions), format: :json)
    else
      language = params[:lang] || self.default_doc_language
      render(response, Angus::SDoc::HtmlFormatter.format_service(@definitions, language),
             format: :html)
    end
  end
end