An example chat server in golang.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

26 lines
854 B

<!DOCTYPE html>
<html>
<head><title>Sample Chat</title></head>
<body>
<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":"jon@example.com"}'
# Validate auth code (swap session id, sub, and otp)
curl -X POST http://localhost:4080/api/sessions/xyz \
-H 'Content-Type: application/json; charset=utf-8' \
-d '{"otp":"secret123"}'
# Post a message (swap api-token)
curl -X POST http://localhost:4080/api/rooms/general \
-H 'Authorization: Bearer api-token' \
-H 'Content-Type: application/json; charset=utf-8' \
-d '{"message":"hello"}'
# Get a room's messages (swap api-token, since unix-epoch)
curl http://localhost:4080/api/rooms/general?since=0 \
-H 'Authorization: Bearer api-token'
</code></pre>
</body>
</html>