68 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			68 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<!DOCTYPE html>
 | 
						|
<html>
 | 
						|
  <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><email></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)
 | 
						|
 | 
						|
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><msg></em></strong>"}</code>
 | 
						|
    </h3>
 | 
						|
    <pre><code># 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></code>
 | 
						|
    </h3>
 | 
						|
    <pre><code># Get a room's messages (swap api-token, since unix-epoch)
 | 
						|
 | 
						|
curl http://localhost:4080/api/rooms/general \
 | 
						|
  -H 'Authorization: Bearer <strong><em>api-token</em></strong>'
 | 
						|
    </code></pre>
 | 
						|
    </li>
 | 
						|
    </ul>
 | 
						|
  </body>
 | 
						|
</html>
 |