Namdak Tonpa 5 лет назад
Родитель
Сommit
e98e564dfc
1 измененных файлов с 31 добавлено и 31 удалено
  1. 31 31
      index.html

+ 31 - 31
index.html

@@ -7,7 +7,8 @@
 <meta name="description" content="" />
 <meta name="author" content="Maxim Sokhatsky" />
 <title>REST</title>
-<link rel="stylesheet" href="https://n2o.dev/blank.css" /><link rel="stylesheet" href="https://n2o.dev/zima.css" />
+<link rel="stylesheet" href="https://n2o.dev/blank.css" />
+<link rel="stylesheet" href="https://n2o.dev/zima.css" />
 </head>
 <body>
 <nav>
@@ -24,12 +25,11 @@
     <article>
         <section>
             <h3>SYNOPSIS</h3>
-            <div>REST: framework with typed JSON<br /><br />
-                 <b>Features and Goals</b><br /><br />
+            <div>REST is a framework with typed JSON. Features and Goals: <br /><br />
                  1. Fastest possible Record &#60;-&#62; Proplists transformations<br />
                  2. Smallest REST framework in the world<br />
                  3. ETS/KVS/Any storage selection by scaffolding<br /><br />
-                 We&#39;ve achived first goal by providing parse_transform code generation for tuple transformations.
+                 We've achived first goal by providing parse_transform code generation for tuple transformations.
                  And second requirement was achieved by not including routing bullshit and other uncertain features.
             </div>
         </section>
@@ -39,8 +39,10 @@
             <div>Just plug REST endpoint directly to your Cowboy router:</div>
         <figure>
         <code>
-  {"/rest/:resource", rest_cowboy, []},
-  {"/rest/:resource/:id", rest_cowboy, []},
+ {"/:res",rest_cowboy,[]},
+ {"/:res/:id",rest_cowboy,[]},
+ {"/kvs/0/[...]",rest_kvs,[]},
+ {"/kvs/1/:id/[...]",rest_kvs,[]},
         </code>
         </figure>
             <div>
@@ -58,39 +60,37 @@
         </p>
         <figure>
         <code>
--module(users).
--behaviour(rest).
--compile({parse_transform, rest}).
--include("users.hrl").
--export([init/0, populate/1, exists/1, get/0, get/1, post/1, delete/1]).
--rest_record(user).
+ -module(users).
+ -behaviour(rest).
+ -compile({parse_transform, rest}).
+ -include("users.hrl").
+ -export([init/0, populate/1, exists/1, get/0, get/1, post/1, delete/1]).
+ -rest_record(user).
 
-init() -> ets:new(users, [public, named_table, {keypos, #user.id}]).
-populate(Users) -> ets:insert(users, Users).
-exists(Id) -> ets:member(users, wf:to_list(Id)).
-get() -> ets:tab2list(users).
-get(Id) -> [User] = ets:lookup(users, wf:to_list(Id)), User.
-delete(Id) -> ets:delete(users, wf:to_list(Id)).
-post(#user{} = User) -> ets:insert(users, User);
-post(Data) -> post(from_json(Data, #user{})).
+ init() -> ets:new(users, [public, named_table, {keypos, #user.id}]).
+ populate(Users) -> ets:insert(users, Users).
+ exists(Id) -> ets:member(users, wf:to_list(Id)).
+ get() -> ets:tab2list(users).
+ get(Id) -> [User] = ets:lookup(users, wf:to_list(Id)), User.
+ delete(Id) -> ets:delete(users, wf:to_list(Id)).
+ post(#user{} = User) -> ets:insert(users, User);
+ post(Data) -> post(from_json(Data, #user{})).
         </code>
         </figure>
     </section>
     <section>
-        <a name="usage2"></a><h3>Usage</h3>
-        <figure>
-        <code>
-$ curl -i -X POST -d "id=vlad" localhost:8005/rest/users
-$ curl -i -X POST -d "id=doxtop" localhost:8005/rest/users
-$ curl -i -X GET localhost:8005/rest/users
-$ curl -i -X PUT -d "id=5HT" localhost:8005/rest/users/vlad
-$ curl -i -X GET localhost:8005/rest/users/5HT
-$ curl -i -X DELETE localhost:8005/rest/users/5HT
+        <<h3>Usage</h3>
+        <figure><code>
+ $ curl -i -X POST -d "id=vlad" localhost:8005/rest/users
+ $ curl -i -X POST -d "id=doxtop" localhost:8005/rest/users
+ $ curl -i -X GET localhost:8005/rest/users
+ $ curl -i -X PUT -d "id=5HT" localhost:8005/rest/users/vlad
+ $ curl -i -X GET localhost:8005/rest/users/5HT
+ $ curl -i -X DELETE localhost:8005/rest/users/5HT
         </code></figure>
     </section>
-
     <section>
-        <a name="modules"></a><h3>Modules</h3>
+        <h3>Modules</h3>
         <ul><li><b><a href="man/rest.htm">rest</a></b> — rest</li>
             <li><b><a href="man/rest_app.htm">rest_app</a></b> — rest_app</li>
             <li><b><a href="man/rest_cowboy.htm">rest_cowboy</a></b> — rest_cowboy</li>