AJ ONeal
6 years ago
1 changed files with 47 additions and 5 deletions
@ -1,26 +1,68 @@ |
|||||
<!DOCTYPE html> |
<!DOCTYPE html> |
||||
<html> |
<html> |
||||
<head><title>Sample Chat</title></head> |
<head><title>API Docs</title></head> |
||||
<body> |
<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) |
<pre><code># Ask for an auth code (swap sub) |
||||
|
|
||||
curl -X POST http://localhost:4080/api/sessions \ |
curl -X POST http://localhost:4080/api/sessions \ |
||||
-H 'Content-Type: application/json; charset=utf-8' \ |
-H 'Content-Type: application/json; charset=utf-8' \ |
||||
-d '{"sub":"<strong><em>jon@example.com</em></strong>"}' |
-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> \ |
curl -X POST http://localhost:4080/api/sessions/<strong><em>xyz</em></strong> \ |
||||
-H 'Content-Type: application/json; charset=utf-8' \ |
-H 'Content-Type: application/json; charset=utf-8' \ |
||||
-d '{"otp":"<strong><em>secret123</em></strong>"}' |
-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 \ |
curl -X POST http://localhost:4080/api/rooms/general \ |
||||
-H 'Authorization: Bearer <strong><em>api-token</em></strong>' \ |
-H 'Authorization: Bearer <strong><em>api-token</em></strong>' \ |
||||
-H 'Content-Type: application/json; charset=utf-8' \ |
-H 'Content-Type: application/json; charset=utf-8' \ |
||||
-d '{"message":"Hello, World!"}' |
-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 \ |
||||
curl http://localhost:4080/api/rooms/general?since=0 \ |
|
||||
-H 'Authorization: Bearer <strong><em>api-token</em></strong>' |
-H 'Authorization: Bearer <strong><em>api-token</em></strong>' |
||||
</code></pre> |
</code></pre> |
||||
|
</li> |
||||
|
</ul> |
||||
</body> |
</body> |
||||
</html> |
</html> |
||||
|
Loading…
Reference in new issue