221V 5 years ago
parent
commit
7a549142e4
10 changed files with 393 additions and 12 deletions
  1. 110 0
      index.html
  2. 3 3
      man/rest.htm
  3. 3 3
      man/rest_app.htm
  4. 3 3
      man/rest_cowboy.htm
  5. 3 3
      man/rest_sup.htm
  6. 110 0
      man/ua/index.html
  7. 41 0
      man/ua/rest.htm
  8. 41 0
      man/ua/rest_app.htm
  9. 41 0
      man/ua/rest_cowboy.htm
  10. 38 0
      man/ua/rest_sup.htm

+ 110 - 0
index.html

@@ -0,0 +1,110 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8" />
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta name="viewport" content="width=device-width, initial-scale=1.0" />
+<meta name="description" content="" />
+<meta name="author" content="Maxim Sokhatsky" />
+<title>REST</title>
+<link rel="stylesheet" href="https://synrc.space/synrc.css" />
+</head>
+<body>
+<nav>
+    <a href="https://n2o.dev">DEV</a>
+    <a href="#" style="background:#ededed;">REST</a>
+    <a href="man/ua/index.html">UA</a>
+    <a href="#" style="background:#ededed;">EN</a>
+</nav>
+<header>
+    <a href="https://github.com/synrc/rest"><img src="https://synrc.space/images/Synrc Neo.svg?v=1" /></a>
+    <h1>REST</h1>
+</header>
+<aside>
+    <article>
+        <section>
+            <h3>SYNOPSIS</h3>
+            <div>REST: framework with typed JSON<br /><br />
+                 <b>Features and Goals</b><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.
+                 And second requirement was achieved by not including routing bullshit and other uncertain features.
+            </div>
+        </section>
+
+        <section>
+            <a name="usage"></a><h3>USAGE</h3>
+            <div>Just plug REST endpoint directly to your Cowboy router:</div>
+        <figure>
+        <code>
+  {"/rest/:resource", rest_cowboy, []},
+  {"/rest/:resource/:id", rest_cowboy, []},
+        </code>
+        </figure>
+            <div>
+                OCT 2018 © <a href="https://github.com/5HT">5HT</a> <a href="https://5ht.co/license.htm">ISC</a><br />
+                VER 5.10
+            </div>
+        </section>
+    </article>
+</aside>
+<main>
+    <section>
+        <a name="module"></a><h3>Module</h3>
+        <p>
+            Sample REST service implementation:
+        </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).
+
+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
+        </code></figure>
+    </section>
+
+    <section>
+        <a name="modules"></a><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>
+            <li><b><a href="man/rest_sup.htm">rest_sup</a></b> — rest_sup</li>
+        </ul>
+    </section>
+
+    <section>
+        <a name="credits"></a><h3>Credits</h3>
+        <ul><li>Dmitry Bushmelev</li></ul>
+    </section>
+</main>
+<footer>
+    Made with <span class="heart">❤</span> to Erlang
+</footer>
+</body>
+</html>

+ 3 - 3
man/rest.htm

@@ -1,4 +1,4 @@
-<html><head><meta charset="utf-8" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="description" content="" /><meta name="author" content="Maxim Sokhatsky" /><title>REST</title><link rel="stylesheet" href="https://synrc.space/synrc.css" /></head><body><nav>
+<!DOCTYPE html><html><head><meta charset="utf-8" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="description" content="" /><meta name="author" content="Maxim Sokhatsky" /><title>REST</title><link rel="stylesheet" href="https://synrc.space/synrc.css" /></head><body><nav>
     <a href="https://n2o.dev">DEV</a>
     <a href="https://n2o.dev">DEV</a>
     <a href="https://rest.n2o.space">REST</a>
     <a href="https://rest.n2o.space">REST</a>
     <a href="#" style="background:#ededed;">REST</a>
     <a href="#" style="background:#ededed;">REST</a>
@@ -18,5 +18,5 @@ MAN_MODULES
 </p>
 </p>
     </section>
     </section>
 </main><footer>
 </main><footer>
-    20052019 © Synrc Research Center
-</footer></body></html>
+    2005&#8211;2019 © Synrc Research Center
+</footer></body></html>

+ 3 - 3
man/rest_app.htm

@@ -1,4 +1,4 @@
-<html><head><meta charset="utf-8" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="description" content="" /><meta name="author" content="Maxim Sokhatsky" /><title>APP</title><link rel="stylesheet" href="https://synrc.space/synrc.css" /></head><body><nav>
+<!DOCTYPE html><html><head><meta charset="utf-8" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="description" content="" /><meta name="author" content="Maxim Sokhatsky" /><title>APP</title><link rel="stylesheet" href="https://synrc.space/synrc.css" /></head><body><nav>
     <a href="https://n2o.dev">DEV</a>
     <a href="https://n2o.dev">DEV</a>
     <a href="https://rest.n2o.space">REST</a>
     <a href="https://rest.n2o.space">REST</a>
     <a href="#" style="background:#ededed;">APP</a>
     <a href="#" style="background:#ededed;">APP</a>
@@ -18,5 +18,5 @@ MAN_MODULES
 </p>
 </p>
     </section>
     </section>
 </main><footer>
 </main><footer>
-    20052019 © Synrc Research Center
-</footer></body></html>
+    2005&#8211;2019 © Synrc Research Center
+</footer></body></html>

+ 3 - 3
man/rest_cowboy.htm

@@ -1,4 +1,4 @@
-<html><head><meta charset="utf-8" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="description" content="" /><meta name="author" content="Maxim Sokhatsky" /><title>COWBOY</title><link rel="stylesheet" href="https://synrc.space/synrc.css" /></head><body><nav>
+<!DOCTYPE html><html><head><meta charset="utf-8" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="description" content="" /><meta name="author" content="Maxim Sokhatsky" /><title>COWBOY</title><link rel="stylesheet" href="https://synrc.space/synrc.css" /></head><body><nav>
     <a href="https://n2o.dev">DEV</a>
     <a href="https://n2o.dev">DEV</a>
     <a href="https://rest.n2o.space">REST</a>
     <a href="https://rest.n2o.space">REST</a>
     <a href="#" style="background:#ededed;">COWBOY</a>
     <a href="#" style="background:#ededed;">COWBOY</a>
@@ -18,5 +18,5 @@ MAN_MODULES
 </p>
 </p>
     </section>
     </section>
 </main><footer>
 </main><footer>
-    20052019 © Synrc Research Center
-</footer></body></html>
+    2005&#8211;2019 © Synrc Research Center
+</footer></body></html>

+ 3 - 3
man/rest_sup.htm

@@ -1,4 +1,4 @@
-<html><head><meta charset="utf-8" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="description" content="" /><meta name="author" content="Maxim Sokhatsky" /><title>SUP</title><link rel="stylesheet" href="https://synrc.space/synrc.css" /></head><body><nav>
+<!DOCTYPE html><html><head><meta charset="utf-8" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="description" content="" /><meta name="author" content="Maxim Sokhatsky" /><title>SUP</title><link rel="stylesheet" href="https://synrc.space/synrc.css" /></head><body><nav>
     <a href="https://n2o.dev">DEV</a>
     <a href="https://n2o.dev">DEV</a>
     <a href="https://rest.n2o.space">REST</a>
     <a href="https://rest.n2o.space">REST</a>
     <a href="#" style="background:#ededed;">SUP</a>
     <a href="#" style="background:#ededed;">SUP</a>
@@ -18,5 +18,5 @@ MAN_MODULES
 </p>
 </p>
     </section>
     </section>
 </main><footer>
 </main><footer>
-    20052019 © Synrc Research Center
-</footer></body></html>
+    2005&#8211;2019 © Synrc Research Center
+</footer></body></html>

+ 110 - 0
man/ua/index.html

@@ -0,0 +1,110 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8" />
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta name="viewport" content="width=device-width, initial-scale=1.0" />
+<meta name="description" content="" />
+<meta name="author" content="Maxim Sokhatsky" />
+<title>REST</title>
+<link rel="stylesheet" href="https://tonpa.guru/blank.css?v=2" />
+</head>
+<body>
+<nav>
+    <a href="https://n2o.dev/ua/">DEV</a>
+    <a href="#" style="background:#ededed;">REST</a>
+    <a href="#" style="background:#ededed;">UA</a>
+    <a href="../../index.html">EN</a>
+</nav>
+<header>
+    <a href="https://github.com/synrc/rest"><img src="https://synrc.space/images/Synrc Neo.svg?v=1" /></a>
+    <h1>REST</h1>
+</header>
+<aside>
+    <article>
+        <section>
+            <h3>СИНОПСИС</h3>
+            <div>REST: фреймворк з типізованим JSON<br /><br />
+                 <b>Переваги та цілі</b><br /><br />
+                 1. Найшвидші можливі Record &#60;-&#62; Proplists перетворення<br />
+                 2. Найменший REST фреймворк у світі<br />
+                 3. ETS/KVS/Будь-яка база даних, просте налаштування<br /><br />
+                 Ми досягли першої мети, визначаючи генерацію коду parse_transform для перетворень кортежів.
+                 Друга вимога була досягнута за допомогою виключення з кодової бази фреймворка зайвого роутингу та інших сумнівних моментів.
+            </div>
+        </section>
+
+        <section>
+            <a name="usage"></a><h3>ВИКОРИСТАННЯ</h3>
+            <div>Просто підключіть кінцеву точку REST безпосередньо до вашого Cowboy роутера:</div>
+        <figure>
+        <code>
+  {"/rest/:resource", rest_cowboy, []},
+  {"/rest/:resource/:id", rest_cowboy, []},
+        </code>
+        </figure>
+            <div>
+                OCT 2018 © <a href="https://github.com/5HT">5HT</a> <a href="https://5ht.co/license.htm">ISC</a><br />
+                VER 5.10
+            </div>
+        </section>
+    </article>
+</aside>
+<main>
+    <section>
+        <a name="module"></a><h3>Модуль</h3>
+        <p>
+            Приклад реалізації REST API:
+        </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).
+
+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>Використання API</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>Модулі</h3>
+        <ul><li><b><a href="rest.htm">rest</a></b> — rest</li>
+            <li><b><a href="rest_app.htm">rest_app</a></b> — rest_app</li>
+            <li><b><a href="rest_cowboy.htm">rest_cowboy</a></b> — rest_cowboy</li>
+            <li><b><a href="rest_sup.htm">rest_sup</a></b> — rest_sup</li>
+        </ul>
+    </section>
+
+    <section>
+        <a name="credits"></a><h3>Credits</h3>
+        <ul><li>Dmitry Bushmelev</li></ul>
+    </section>
+</main>
+<footer>
+    Made with <span class="heart">❤</span> to Erlang
+</footer>
+</body>
+</html>

+ 41 - 0
man/ua/rest.htm

@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8" />
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta name="viewport" content="width=device-width, initial-scale=1.0" />
+<meta name="description" content="" />
+<meta name="author" content="Maxim Sokhatsky" />
+<title>REST</title>
+<link rel="stylesheet" href="https://tonpa.guru/blank.css?v=2" />
+</head>
+<body>
+    <nav>
+    <a href="https://n2o.dev">DEV</a>
+    <a href="https://rest.n2o.space">REST</a>
+    <a href="#" style="background:#ededed;">REST</a>
+    <a href="#" style="background:#ededed;">UA</a>
+    <a href="../rest.htm">EN</a>
+</nav>
+<header>
+    <a href="index.html"><img src="https://n2o.space/img/Synrc Neo.svg" /></a>
+    <h1>REST</h1>
+</header>
+<main>
+    <section>
+
+<h3>ВСТУП</h3>
+
+<p>Модуль REST</p>
+    </section>
+    <section>
+<p>Цей модуль може бути пов'язаним з:
+MAN_MODULES
+</p>
+    </section>
+</main>
+<footer>
+    2005&#8211;2019 © Synrc Research Center
+</footer>
+</body>
+</html>

+ 41 - 0
man/ua/rest_app.htm

@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8" />
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta name="viewport" content="width=device-width, initial-scale=1.0" />
+<meta name="description" content="" />
+<meta name="author" content="Maxim Sokhatsky" />
+<title>APP</title>
+<link rel="stylesheet" href="https://tonpa.guru/blank.css?v=2" />
+</head>
+<body>
+<nav>
+    <a href="https://n2o.dev">DEV</a>
+    <a href="https://rest.n2o.space">REST</a>
+    <a href="#" style="background:#ededed;">APP</a>
+    <a href="#" style="background:#ededed;">UA</a>
+    <a href="../rest_app.htm">EN</a>
+</nav>
+<header>
+    <a href="index.html"><img src="https://n2o.space/img/Synrc Neo.svg" /></a>
+    <h1>APP</h1>
+</header>
+<main>
+   <section>
+
+<h3>ВСТУП</h3>
+
+<p>Модуль APP</p>
+    </section>
+    <section>
+<p>Цей модуль може бути пов'язаним з:
+MAN_MODULES
+</p>
+    </section>
+</main>
+<footer>
+    2005&#8211;2019 © Synrc Research Center
+</footer>
+</body>
+</html>

+ 41 - 0
man/ua/rest_cowboy.htm

@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8" />
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta name="viewport" content="width=device-width, initial-scale=1.0" />
+<meta name="description" content="" />
+<meta name="author" content="Maxim Sokhatsky" />
+<title>COWBOY</title>
+<link rel="stylesheet" href="https://tonpa.guru/blank.css?v=2" />
+</head>
+<body>
+<nav>
+    <a href="https://n2o.dev">DEV</a>
+    <a href="https://rest.n2o.space">REST</a>
+    <a href="#" style="background:#ededed;">COWBOY</a>
+    <a href="#" style="background:#ededed;">UA</a>
+    <a href="../rest_cowboy.htm">EN</a>
+</nav>
+<header>
+    <a href="index.html"><img src="https://n2o.space/img/Synrc Neo.svg" /></a>
+    <h1>COWBOY</h1>
+</header>
+<main>
+    <section>
+
+<h3>ВСТУП</h3>
+
+<p>Модуль COWBOY</p>
+    </section>
+    <section>
+<p>Цей модуль може бути пов'язаним з:
+MAN_MODULES
+</p>
+    </section>
+</main>
+<footer>
+    2005&#8211;2019 © Synrc Research Center
+</footer>
+</body>
+</html>

+ 38 - 0
man/ua/rest_sup.htm

@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8" />
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta name="viewport" content="width=device-width, initial-scale=1.0" />
+<meta name="description" content="" />
+<meta name="author" content="Maxim Sokhatsky" />
+<title>SUP</title>
+<link rel="stylesheet" href="https://tonpa.guru/blank.css?v=2" />
+</head>
+<body>
+<nav>
+    <a href="https://n2o.dev">DEV</a>
+    <a href="https://rest.n2o.space">REST</a>
+    <a href="#" style="background:#ededed;">SUP</a>
+    <a href="#" style="background:#ededed;">UA</a>
+    <a href="../rest_sup.htm">EN</a>
+</nav>
+<header>
+    <a href="index.html"><img src="https://n2o.space/img/Synrc Neo.svg" /></a>
+    <h1>SUP</h1>
+</header>
+<main>
+    <section>
+
+<h3>ВСТУП</h3>
+
+<p>Модуль SUP</p>
+    </section>
+    <section>
+<p>Цей модуль може бути пов'язаним з:
+MAN_MODULES
+</p>
+    </section>
+</main><footer>
+    2005&#8211;2019 © Synrc Research Center
+</footer></body></html>