Module: DbAgile::Restful::Middleware::Get

Included in:
OneDatabase
Defined in:
lib/dbagile/restful/middleware/get.rb

Instance Method Summary collapse

Instance Method Details

#get(env) ⇒ Object

Implements GET access of the restful interface



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/dbagile/restful/middleware/get.rb', line 7

def get(env)
  request = Rack::Request.new(env)
  decode(env) do |connection, table, format|
    # Compute the projection on query string
    heading = connection.heading(table)
    projection = params_to_tuple(request.GET, heading)

    # Retrieve dataset
    columns = connection.column_names(table)
    dataset = connection.dataset(table, projection)

    # Make output now
    format ||= :json 
    [format, to_xxx_enumerable(format, dataset, columns)]
  end
end