Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/synrc/rest
Browse files Browse the repository at this point in the history
  • Loading branch information
5HT committed May 19, 2014
2 parents f0cc284 + bb7b2de commit 1c091ab
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
24 changes: 22 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
REST: N2O separate endpoint
===========================
REST: framework with typed JSON
===============================

Usage
-----

Just plug REST endpoint directly to your Cowboy router:

```erlang
{"/rest/:resource", rest_cowboy, []},
{"/rest/:resource/:id", rest_cowboy, []},
Expand All @@ -12,6 +14,8 @@ Usage
Module
------

Sample REST service implementation:

```erlang
-module(users).
-behaviour(rest).
Expand All @@ -30,3 +34,19 @@ post(#user{} = User) -> ets:insert(users, User);
post(Data) -> post(from_json(Data, #user{})).
```

Usage
-----

curl -i -X POST -d "id=vlad" localhost:8000/rest/users
curl -i -X POST -d "id=doxtop" localhost:8000/rest/users
curl -i -X GET localhost:8000/rest/users
curl -i -X PUT -d "id=5HT" localhost:8000/rest/users/vlad
curl -i -X GET localhost:8000/rest/users/5HT
curl -i -X DELETE localhost:8000/rest/users/5HT

Credits
-------

* Dmitry Bushmelev

OM A HUM
2 changes: 1 addition & 1 deletion src/rest.app.src
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{application, rest, [
{description, "REST SXC"},
{vsn, "3.0"},
{applications, [kernel, stdlib, cowboy, ranch, gproc, mimetypes, erlydtl]},
{applications, [kernel, stdlib, cowboy]},
{modules, []},
{registered, []},
{mod, { rest_app, []}},
Expand Down

0 comments on commit 1c091ab

Please sign in to comment.