Simple Golang REST application with Gorilla Mux
These are the steps to run this app:
- Make sure Golang, DEP Package Manager, and MongoDB are installed
- Create new project on sentry.io for your logger
- Clone this repository to your dir, eg.
$GOPATH/src/github.com/sangianpatrick
- Go to project root directory (
$GOPATH/src/github.com/sangianpatrick/go-rest-mux
) - Populate the env file
./.env.example
with your own configuration and copy to./.env
- Run command
dep ensure
to install the dependencies - Run command
make test
to run the unit testing - Run command
make dev
to run app on development environment or - Run command
make run
to create and run from app's executable
{ Authorization: "Basic <token> }"
or { Authorization: "Bearer <token>" }
and { Content-Type: "application/json" }
{
"success": false,
"message":"Error message",
"code": "<HTTP_ERROR_CODE> [400,401,404,409]"
}
{
"success": true,
"data": "<MULTI DATA TYPE: array, string, int and object>",
"message":"Success message",
"code": "<HTTP_SUCCESS_CODE> [200, 201]"
}
{
"success": true,
"data": "<DATA TYPE: array>",
"message":"Success message",
"code": "<HTTP_SUCCESS_CODE> [200]",
"meta": {
"totalPage": 20,
"page": 1,
"totalData": 200,
"totalDataOnPage": 10
}
}
Method | Authorization | URI | Description |
---|---|---|---|
POST | Basic {token} | /api/v1/auth/signin | User signin. |
POST | Basic {token} | /api/v1/users/registration | Create new user. |
GET | Bearer {token} | /api/v1/users/profile/me | Get my profile. |
GET | Bearer {token} | /api/v1/users?page=1&size=10 | Get list of user depends on page and size. |
GET | Bearer {token} | /api/v1/users/{userID} | Get one user with ID. |
PUT | Bearer {token} | /api/v1/users/profile/me | Update authorized user property. |
DELETE | Bearer {token} | /api/v1/users/profile/me | Delete authorized user account. |
POST | Bearer {token} | /api/v1/users/article | Create authorized user's article. |