A Go API made for studies that manages tasks with user authentication
POST
/register
(registers new user)
name |
type |
data type |
email |
required |
string (valid email) |
password |
required |
string |
http code |
content-type |
response |
201 |
application/json |
{"ok":"use /login to authenticate"} |
400 |
application/json |
{"description":"Validation error","error":"Key: 'User.Email' Error:Field validation for 'Email' failed on the 'email' tag"} |
400 |
application/json |
{"description":"Validation error","error":"Key: 'UserDTO.Email' Error:Field validation for 'Email' failed on the 'required' tag"} |
400 |
application/json |
{"description":"Validation error","error":"Key: 'UserDTO.Password' Error:Field validation for 'Password' failed on the 'required' tag"} |
POST
/login
(logs in user)
name |
type |
data type |
email |
required |
string |
password |
required |
string |
http code |
content-type |
response |
200 |
application/json |
{"token":"..."} |
400 |
application/json |
{"description":"Validation error","error":"Key: 'UserDTO.Email' Error:Field validation for 'Email' failed on the 'required' tag"} |
400 |
application/json |
{"description":"Validation error","error":"Key: 'UserDTO.Password' Error:Field validation for 'Password' failed on the 'required' tag"} |
400 |
application/json |
{"description":"Validation error","error":"crypto/bcrypt: hashedPassword is not the hash of the given password"} |
500 |
application/json |
{"description":"Repository error","error":"User not found"} |
PATCH
/user
(updates user's properties)
name |
type |
data type |
email |
optional |
string |
password |
optional |
string |
Headers
name |
data type |
Authorization |
string (JWT token) |
| http code | content-type | response |
| --------- | ------------------ | ----------------------------------------------------------------------------------------------------------------------------- | --- | --- |
| 200
| application/json
| {"status":"success"}
|
| 400
| application/json
| {"description":"Validation error","error":"Key: 'User.Email' Error:Field validation for 'Email' failed on the 'email' tag"}
| | |
| 401
| application/json
| {"description":"You must be authenticated","error":"token is malformed: ..."}
| | |
| 401
| application/json
| {"description":"You must be authenticated","error":"Authorization header not found"}
| | |
| 401
| application/json
| {"description":"You must be authenticated","error":"token has invalid claims: token is expired"}
| | |
DELETE
/user
(deletes user)
Headers
name |
data type |
Authorization |
string (JWT token) |
| http code | content-type | response |
| --------- | ------------------ | -------------------------------------------------------------------------------------------------- | --- | --- |
| 200
| application/json
| {"status":"success"}
|
| 401
| application/json
| {"description":"You must be authenticated","error":"token is malformed: ..."}
| | |
| 401
| application/json
| {"description":"You must be authenticated","error":"Authorization header not found"}
| | |
| 401
| application/json
| {"description":"You must be authenticated","error":"token has invalid claims: token is expired"}
| | |
GET
/tasks
(gets all authenticated user's tasks)
Headers
name |
data type |
Authorization |
string (JWT token) |
| http code | content-type | response |
| --------- | ------------------ | -------------------------------------------------------------------------------------------------- | --- | --- |
| 200
| application/json
| [{...}]
|
| 401
| application/json
| {"description":"You must be authenticated","error":"token is malformed: ..."}
| | |
| 401
| application/json
| {"description":"You must be authenticated","error":"Authorization header not found"}
| | |
| 401
| application/json
| {"description":"You must be authenticated","error":"token has invalid claims: token is expired"}
| | |
GET
/tasks/:id
(gets a task in authenticated user's tasks)
Headers
name |
data type |
Authorization |
string (JWT token) |
| http code | content-type | response |
| --------- | ------------------ | -------------------------------------------------------------------------------------------------- | --- | --- |
| 200
| application/json
| {...} | |
|
| 400
| application/json
| {"description":"Validation error","error":"invalid UUID length: ..."}
| | |
| 401
| application/json
| {"description":"You must be authenticated","error":"token is malformed: ..."}
| | |
| 401
| application/json
| {"description":"You must be authenticated","error":"Authorization header not found"}
| | |
| 401
| application/json
| {"description":"You must be authenticated","error":"token has invalid claims: token is expired"}
| | |
| 500
| application/json
| {"description":"Repository error","error":"Task not found"}
|
POST
/tasks
(creates a task in authenticated user's tasks list)
name |
type |
data type |
title |
required |
string |
description |
optional |
string |
toDate |
required |
string (dd/mm/yy hh:mm) |
tags |
optional |
[]string |
Headers
name |
data type |
Authorization |
string (JWT token) |
| http code | content-type | response |
| --------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------- | --- | --- |
| 201
| application/json
| {"createdTaskId":"..."}
|
| 400
| application/json
| {"description":"Validation error","error":"Key: 'CreateTaskDTO.Title' Error:Field validation for 'Title' failed on the 'required' tag"}
| | |
| 400
| application/json
| {"description":"Validation error","error":"Key: 'CreateTaskDTO.ToDate' Error:Field validation for 'ToDate' failed on the 'required' tag"}
| | |
| 400
| application/json
| {"description":"Validation error","error":"parsing time..."}
| | |
| 401
| application/json
| {"description":"You must be authenticated","error":"token is malformed: ..."}
| | |
| 401
| application/json
| {"description":"You must be authenticated","error":"Authorization header not found"}
| | |
| 401
| application/json
| {"description":"You must be authenticated","error":"token has invalid claims: token is expired"}
| | |
PATCH
/tasks/:id
(updates a task in authenticated user's tasks list)
name |
type |
data type |
title |
optional |
string |
description |
optional |
string |
toDate |
optional |
string (dd/mm/yy hh:mm) |
completed |
optional |
bool |
tags |
optional |
[]string |
Headers
name |
data type |
Authorization |
string (JWT token) |
| http code | content-type | response |
| --------- | ------------------ | -------------------------------------------------------------------------------------------------- | --- | --- |
| 200
| application/json
| {"status":"success"}
|
| 400
| application/json
| {"description":"Validation error","error":"parsing time..."}
| | |
| 400
| application/json
| {"description":"Validation error","error":"invalid UUID length: ..."}
| | |
| 401
| application/json
| {"description":"You must be authenticated","error":"token is malformed: ..."}
| | |
| 401
| application/json
| {"description":"You must be authenticated","error":"Authorization header not found"}
| | |
| 401
| application/json
| {"description":"You must be authenticated","error":"token has invalid claims: token is expired"}
| | |
| 500
| application/json
| {"description":"Repository error","error":"Task not found"}
|
DELETE
/tasks/:id
(deletes a task in authenticated user's tasks list)
Headers
name |
data type |
Authorization |
string (JWT token) |
| http code | content-type | response |
| --------- | ------------------ | -------------------------------------------------------------------------------------------------- | --- | --- |
| 200
| application/json
| {"status":"success"}
|
| 400
| application/json
| {"description":"Validation error","error":"parsing time..."}
| | |
| 400
| application/json
| {"description":"Validation error","error":"invalid UUID length: ..."}
| | |
| 401
| application/json
| {"description":"You must be authenticated","error":"token is malformed: ..."}
| | |
| 401
| application/json
| {"description":"You must be authenticated","error":"Authorization header not found"}
| | |
| 401
| application/json
| {"description":"You must be authenticated","error":"token has invalid claims: token is expired"}
| | |
| 500
| application/json
| {"description":"Repository error","error":"Task not found"}
|