AJ ONeal
6 роки тому
1 змінених файлів з 47 додано та 5 видалено
@ -1,26 +1,68 @@ |
|||
<!DOCTYPE html> |
|||
<html> |
|||
<head><title>Sample Chat</title></head> |
|||
<head><title>API Docs</title></head> |
|||
<body> |
|||
<h1>Sample Chat - API Docs</h1> |
|||
|
|||
|
|||
<h2>Login</h2> |
|||
<ul> |
|||
<li> |
|||
<h3>POST /api/sessions |
|||
<br> |
|||
<code>{"sub":"<strong><em>jon@example.com</em></strong>"}</code> |
|||
</h3> |
|||
<pre><code># Ask for an auth code (swap sub) |
|||
|
|||
curl -X POST http://localhost:4080/api/sessions \ |
|||
-H 'Content-Type: application/json; charset=utf-8' \ |
|||
-d '{"sub":"<strong><em>jon@example.com</em></strong>"}' |
|||
</code></pre> |
|||
</li> |
|||
|
|||
<li> |
|||
<h3>POST /api/sessions/<strong><em>id</em></strong> |
|||
<br> |
|||
<code>{"otp":"<strong><em>auth-code</em></strong>"}</code> |
|||
</h3> |
|||
<pre><code># Validate auth code (swap session id, sub, and otp) |
|||
|
|||
# Validate auth code (swap session id, sub, and otp) |
|||
curl -X POST http://localhost:4080/api/sessions/<strong><em>xyz</em></strong> \ |
|||
-H 'Content-Type: application/json; charset=utf-8' \ |
|||
-d '{"otp":"<strong><em>secret123</em></strong>"}' |
|||
</code></pre> |
|||
</li> |
|||
</ul> |
|||
|
|||
<h2>Messages</h2> |
|||
<ul> |
|||
<li> |
|||
<h3>POST /api/rooms/general |
|||
<br> |
|||
<code>Authorization: Bearer <strong><em>api-token</em></strong> |
|||
<br>{"message":"<strong><em>Hello, World!</em></strong>"}</code> |
|||
</h3> |
|||
<pre><code># Post a message (swap api-token) |
|||
|
|||
# Post a message (swap api-token) |
|||
curl -X POST http://localhost:4080/api/rooms/general \ |
|||
-H 'Authorization: Bearer <strong><em>api-token</em></strong>' \ |
|||
-H 'Content-Type: application/json; charset=utf-8' \ |
|||
-d '{"message":"Hello, World!"}' |
|||
</code></pre> |
|||
</li> |
|||
|
|||
<li> |
|||
<h3>GET /api/rooms/general |
|||
<br> |
|||
<code>Authorization: Bearer <strong><em>api-token</em></strong> |
|||
<br>{"message":"<strong><em>Hello, World!</em></strong>"}</code> |
|||
</h3> |
|||
<pre><code># Get a room's messages (swap api-token, since unix-epoch) |
|||
|
|||
# Get a room's messages (swap api-token, since unix-epoch) |
|||
curl http://localhost:4080/api/rooms/general?since=0 \ |
|||
curl http://localhost:4080/api/rooms/general \ |
|||
-H 'Authorization: Bearer <strong><em>api-token</em></strong>' |
|||
</code></pre> |
|||
</li> |
|||
</ul> |
|||
</body> |
|||
</html> |
|||
|
Завантаження…
Посилання в новій проблемі