Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ardwiinoo/chats-api
⚡ Backend for simple chats web
https://github.com/ardwiinoo/chats-api
gin go websocket
Last synced: 30 days ago
JSON representation
⚡ Backend for simple chats web
- Host: GitHub
- URL: https://github.com/ardwiinoo/chats-api
- Owner: ardwiinoo
- Created: 2024-08-24T04:47:00.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-08-26T04:49:16.000Z (3 months ago)
- Last Synced: 2024-10-02T05:21:05.266Z (about 1 month ago)
- Topics: gin, go, websocket
- Language: Go
- Homepage:
- Size: 31.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# API SPEC
## User
### Register
Endpoint: POST /api/users/signup
Request Body :
```json
{
"username": "user",
"email": "[email protected]",
"password": "rahasia"
}
```Response Body (Success) :
```json
{
"id": 1,
"username": "user",
"email": "[email protected]"
}
```Response Body (Failed) :
```json
{
"error": "EOF"
}
```### Login
Endpoint: POST /api/users/signin
Request Body :
```json
{
"email": "[email protected]",
"password": "rahasia"
}
```Response Body (Success) :
**Set-Cookie**: jwt=token; HttpOnly; Path=/; Max-Age=3600
```json
{
"id": 1,
"username": "user"
}
```Response Body (Failed) :
```json
{
"error": "EOF"
}
```### Logout
Endpoint: GET /api/users/logout
**Set-Cookie**: jwt=token; HttpOnly; Path=/; Max-Age=3600
Response Body (Success) :
```json
{
"message": "logout successful"
}
```Response Body (Failed) :
```json
{
"error": "EOF"
}
```## Websocket
### Create Room
Endpoint: POST /ws/create-room
Request Body :
```json
{
"id": 1,
"name": "room1"
}
```Response Body (Success) :
```json
{
"id": 1,
"name": "room1"
}
```Response Body (Failed) :
```json
{
"error": "EOF"
}
```### Join Room
Endpoint: ws://localhost:8080/ws/join-room/:roomId?userId=1&username=user
Response Body (Connected) :
```text
Connected to ws://localhost:8080/ws/join-room/:roomId?userId=1&username=userHandshake details
...
Request Method: "GET"
Status Code: "101 Switching Protocols"
...
```Response Body (Failed) :
```json
{
"error": "EOF"
}
```### Get Rooms
Endpoint: GET /ws/get-rooms
Response Body (Success) :
```json
{
"id": 1,
"name": "room1"
},
{
"id": 2,
"name": "room2"
},
{
"id": 3,
"name": "room3"
}
```### Get Clients
Endpoint: GET /ws/get-clients
Response Body (Success) :
```json
{
"id": 1,
"username": "user1"
},
{
"id": 2,
"username": "user2"
},
{
"id": 3,
"username": "user3"
}
```