Categorygithub.com/danielronalds/messenger-server
modulepackage
0.0.0-20241109020137-df5416b2955a
Repository: https://github.com/danielronalds/messenger-server.git
Documentation: pkg.go.dev

# README

WIP

User Endpoints

GET /users

Gets all registered users

Returns

[
  {
    "username": "example-user",
    "displayname": "Example",
  }
]

POST /users

Creates a new user

Expects

{ 
  "username": "example-user", 
  "displayname": "Example", 
  "password": "terrible-password" 
}

Returns

{ 
  "username": "example-user",
  "displayname": "Example",
}

Auth Endpoints

POST /auth

Creates a user session, returning a session key if authentication is successful

Expects

{
  "username": "example-user",
  "password": "terrible-password"
}

Returns

{
 "key": "OdT7yQCl1a4xoCXc4OB1X7oSZH4q1bSpCuSEtxwLAu3YKaBd1MMwYfTVP/HbJKZJiNQKayi",
 "displayname": "example-user"
}

Key is always unique

DELETE /auth

Deletes a user session, an action that should be taken when logging out.

Expects

{
 "key": "OdT7yQCl1a4xoCXc4OB1X7oSZH4q1bSpCuSEtxwLAu3YKaBd1MMwYfTVP/HbJKZJiNQKayi"
}

The key is the session that will be deleted

Returns

200 OK if all goes well

Message Endpoints

POST /message

Sends a message from the user to another user. Uses authentication.

Expects

{
 "key": "OdT7yQCl1a4xoCXc4OB1X7oSZH4q1bSpCuSEtxwLAu3YKaBd1MMwYfTVP/HbJKZJiNQKayi",
 "to": "example-user",
 "content": "Hello world!"
}

Returns

{
	"id": 1
	"sender": "jonsnow"
	"receiver": "example-user"
	"content": "Hello, world!"
	"delivered": time.Now()
	"isRead": false
}

Inbox Endpoint

POST /inbox

Gets a conversation between the logged in user and the supplied contact. Does not return unread messages from the contact.

Expects

{
 "key": "OdT7yQCl1a4xoCXc4OB1X7oSZH4q1bSpCuSEtxwLAu3YKaBd1MMwYfTVP/HbJKZJiNQKayi",
 "contact": "jonsnow"
}

POST /inbox/unread

Gets unread messages for all contacts.

Expects

{
 "key": "OdT7yQCl1a4xoCXc4OB1X7oSZH4q1bSpCuSEtxwLAu3YKaBd1MMwYfTVP/HbJKZJiNQKayi",
}

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author