Sha256: ac2c1c6be889f1afe1f7b6f422424d893005767ef7acc0fcbd70c36f94e205ae

Contents?: true

Size: 840 Bytes

Versions: 4

Compression:

Stored size: 840 Bytes

Contents

# Get all Features
get "/api/feature/?" do
  features = Feature.all
  case @accept
  when "text/uri-list"
    uri_list = features.collect{|feature| uri("/feature/#{feature.id}")}
    return uri_list.join("\n") + "\n"
  when "application/json"
    features = JSON.parse features.to_json
    list = []
    features.each{|f| list << uri("/feature/#{f["_id"]["$oid"]}")}
    return list.to_json
  else
    bad_request_error "Mime type #{@accept} is not supported."
  end
end

# Get a feature
get "/api/feature/:id/?" do
  case @accept
  when "application/json"
    feature = Feature.find :id => params[:id]
    not_found_error "Feature with id: #{params[:id]} not found." unless feature
    feature[:URI] = uri("/feature/#{feature.id}")
    return feature.to_json
  else
    bad_request_error "Mime type #{@accept} is not supported."
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lazar-gui-1.4.2 lib/feature.rb
lazar-gui-1.4.1 lib/feature.rb
lazar-gui-1.4.0 lib/feature.rb
lazar-gui-1.4.0.pre.0 lib/feature.rb