0.0
No commit activity in last 3 years
No release in over 3 years
A rack application working as an adapter for Mongoid
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.5
= 0.9.12.6
= 0.6.2
>= 0
= 2.14.1

Runtime

>= 1.5.1
>= 0.0.5
>= 4.0.0.alpha2
>= 0
 Project Readme

Rack::Mongoid

Provides RESTful interface for MongoDB as a rack middleware.

Usage

# config/mongoid.yml
production:
  sessions:
    default:
      uri: <%= ENV["MONGOLAB_URI"] %>
# config.ru
require "rack/mongoid"
run Rack::Mongoid
# Gemfile
source "https://rubygems.org"
gem "rack-mongoid"

POST /{resource_name} - Create a new resource

$ curl http://my-example-app.herokuapp.com/users -d '{"name":"alice"}' -H "Content-Type: application/json" -i
HTTP/1.1 201 Created
Content-Type: application/json
Date: Tue, 10 Jun 2014 16:47:26 GMT
Server: WEBrick/1.3.1 (Ruby/2.0.0/2014-05-08)
Content-Length: 59
Connection: keep-alive

{
  "name": "alice",
  "_id": "5397369e3061380002010000"
}

GET /{resource_name} - List resources

$ curl http://my-example-app.herokuapp.com/users -i
HTTP/1.1 200 OK
Content-Type: application/json
Date: Tue, 10 Jun 2014 16:48:19 GMT
Server: WEBrick/1.3.1 (Ruby/2.0.0/2014-05-08)
Content-Length: 109
Connection: keep-alive

[
  {"name":"alice","_id":"5397369e3061380002010000"}
]

GET /{resource_name}/{id} - Show the resource

$ curl http://my-example-app.herokuapp.com/users/5397369e3061380002010000 -i
HTTP/1.1 200 OK
Content-Type: application/json
Date: Tue, 10 Jun 2014 16:48:48 GMT
Server: WEBrick/1.3.1 (Ruby/2.0.0/2014-05-08)
Content-Length: 55
Connection: keep-alive

{"name":"alice","_id":"5397369e3061380002010000"}

PATCH /{resource_name}/{id} - Update the resource

$ curl http://my-example-app.herokuapp.com/users/5397369e3061380002010000 -X PATCH -d '{"name":"bob"}' -H "Content-Type: application/json" -i
HTTP/1.1 200 OK
Content-Type: application/json
Date: Tue, 10 Jun 2014 16:50:15 GMT
Server: WEBrick/1.3.1 (Ruby/2.0.0/2014-05-08)
Content-Length: 48
Connection: keep-alive

{"name":"bob","_id":"5397369e3061380002010000"}

DELETE /{resource_name}/{id} - Delete the resource

$ curl http://my-example-app.herokuapp.com/users/5397369e3061380002010000 -X DELETE -i
HTTP/1.1 200 OK
Content-Type: application/json
Date: Tue, 10 Jun 2014 16:50:47 GMT
Server: WEBrick/1.3.1 (Ruby/2.0.0/2014-05-08)
Content-Length: 48
Connection: keep-alive

{"name":"bob","_id":"5397369e3061380002010000"}