Register a user with username and password.
POST /api/v1/users/register
Request body
{
"username": "string",
"password": "string"
}
Responses
{
"message": "registration success"
}
Login user with username and password.
POST /api/v1/users/login
Request body
{
"username": "string",
"password": "string"
}
Responses
{
"token": "string"
}
Send a message to specific user with the username param or your can read your message inbox if the username in the param is yours.
Websocket /api/v1/users/:username/messages
Message body
{
"content": "string"
}
Responses
{
"content": "string",
"username": "string"
}
You can Subscribe to a channel with a specific name in the channel param, use the command field in the message body with this options for a specific command:
- 0 = Subscribe
- 1 = Unsubscribe
- 2 = Send message
Websocket /api/v1/channels/:channel
Message body
{
"command": 0,
"content": "string"
}
Responses
{
"content": "string",
"channel": "string"
}
users | |
---|---|
id | uint |
username | string |
password | string |
CreatedAt | datetime |
UpdatedAt | datetime |
Messages | |
---|---|
content | string |
channel | string |
username | string |
command | int |
error |
Run project with docker compose
make local.run
Stop all containers
make local.run
Build project
make local.build
Run Tests
make local.test
- Gorilla
- GORM
- Golang-JWT
- Bcrypt
- Rabbitmq/amqp091-go
- Go-redis/redis/v7
- Gorm installation
- User model
- Registration Endpoint
- JWT handler
- Login endpoint
- gorilla installation
- message model
- message creation endpoint
- websocket index endpoint
- message queue
- Users channels