This is a simple twitter-like api written in go as an example to use neo4j with golang.
- neo4j
- postgresql
- mux
- jwt
- go-playground/validator
A guide for endpoints.
Base path: host://api/v1/user
- Register
- Path:
/register/
- Method:
POST
- Request body:
- Path:
{
"username": "username_length_higher_than_6",
"name": "name of user",
"email": "valid_email@example.com",
"password":"a_good_password",
"gender": 1
}
- Response:
{
"status": "Created",
"id": 5,
"token": "<jwt-token>"
}
-
Description: available genders are: Male=1, Female=2, Other=3. use token to access authenticated endpoints.
-
Login
- Path:
/login/
- Method:
POST
- Request body:
- Path:
{
"username": "username",
"password": "user_password"
}
- Response body:
{
"status": "Found",
"id": 5,
"token": "<jwt-token>"
}
- Info
- Auth : need jwt token in headers as Bearer token.
- Path:
/info/{username}
- Method:
GET
- Response Body:
{
"status": "Found",
"data": {
"id": 3,
"username": "username",
"name": "users name",
"email": "valid_email@example.com",
"gender": 1
}
}
- Delete
- Auth
- Path:
/delete/
- Method:
DELETE
- Response Body:
{
"status": "Deleted",
"id": 4
}
Copyright 2023, Max Base