- Starting this web application by the following command.
go run main.go
- When startup is complete, the console shows the following message:
http server started on [::]:8080
- Access http://localhost:8080 in your browser.
- Login with the following username and password.
- username :
test
- password :
test
- username :
Build this source code by the following command.
go build main.go
The follwing figure is the map of this sample project.
+ config … Define configurations of this system.
+ logger … Provide loggers.
+ middleware … Define custom middleware.
+ migration … Provide database migration service for development.
+ router … Define routing.
+ controller … Define controllers.
+ model … Define models.
+ repository … Provide a service of database access.
+ service … Provide a service of book management.
+ session … Provide session management.
- main.go … Entry Point.
This sample provides 3 services: meals, users, and food management.
There are the following services in the Meals management.
Service Name | HTTP Method | URL | Parameter | Summary |
---|---|---|---|---|
Get Service | GET | /api/meal/[MEAL_ID] |
Meal ID | Get a meal data. |
List/Search Service | GET | /api/meal?query=[KEYWORD]&page=[PAGE_NUMBER]&size=[PAGE_SIZE] |
Page, Keyword(Optional) | Get a list of meal. |
Regist Service | POST | /api/meals |
Meal | Regist a meal data. |
There are the following services in the Users management.
Service Name | HTTP Method | URL | Parameter | Summary |
---|---|---|---|---|
Login Service | POST | /api/auth/login |
Session ID, User Name, Password | Session authentication with username and password. |
Logout Service | POST | /api/auth/logout |
Session ID | Logout a user. |
Login Status Check Service | GET | /api/auth/loginStatus |
Session ID | Check if the user is logged in. |
Login Username Service | GET | /api/auth/loginAccount |
Session ID | Get the login user's username. |
There are the following services in the Food management.
Service Name | HTTP Method | URL | Parameter | Summary |
---|---|---|---|---|
Food List Service | GET | /api/foods |
Nothing | Get a list of foods. |