foreman/app/controllers/facts_controller.rb @ ee878ae8
b96931f2 | Ohad Levy | class FactsController < ApplicationController
|
|
ee878ae8 | Ohad Levy | before_filter :valid_request?
|
|
b96931f2 | Ohad Levy | ||
def index
|
|||
5d264a2d | Ohad Levy | render :json => FactName.no_timestamp_fact
|
|
b96931f2 | Ohad Levy | end
|
|
ee878ae8 | Ohad Levy | def show
|
|
@fact = FactName.find(params[:id])
|
|||
begin
|
|||
data = {:name => @fact.name, :values => FactValue.count_each(@fact.name).to_a }
|
|||
rescue
|
|||
data = @fact
|
|||
end
|
|||
render :json => data
|
|||
end
|
|||
private
|
|||
# we currently only support JSON in this controller
|
|||
def valid_request?
|
|||
return not_found unless api_request?
|
|||
end
|
|||
b96931f2 | Ohad Levy | end
|