Minimal API for online ordering in Go
- Start MongoDB database.
docker pull mongo
docker run --name mongodb -d -p 27017:27017 mongo
- Start HTTP server.
git clone https://github.com/codestates/WBABEProject-22.git oos
cd oos
go mod init
go mod tidy
swag init
go run main.go
- Start web browser and go to
http://localhost:8080/swagger/index.html.
- Login as a customer or provider and try endpoints.
- Programming language: Go
- Web framework: Gin
- Database: MongoDB (MongoDB Go Driver)
- Documentation: Swagger (swag)
- Configuration: TOML (go-toml)
- Logging: Zap
config: TOML configurationlogger: Zap log generatordb: MongoDB database and collectionsdto: data transfer objects for requests and responsesmodel: data entitiescontroller: request handlersservice: business logic that interacts with DBrouter: HTTP server that connects HTTP method, URL path, and request handlermiddleware: custom middleware (e.g. CORS, authentication, authorization, etc)docs: OAS2 documentation generated by swaggologs: Log files generated by Zap
- Customer: 주문자
- Query available products and my orders
- Submit orders to providers
- Give feedbacks on products and orders by writing reviews
- Provider: 피주문자
- Query all products and orders
- Create products
- Change order status
| Category | HTTP Method | URL Path | Description |
|---|---|---|---|
| Product | GET |
/products |
메뉴 전체 조회 |
| Product | GET |
/products/{code} |
메뉴 하나 조회 |
| Order | GET |
/{username}/orders/active |
현재 주문 내역 전체 조회 |
| Order | GET |
/{username}/orders/history |
과거 주문 내역 전체 조회 |
| Order | GET |
/orders/{id} |
주문 조회 |
| Order | POST |
/orders |
주문 |
| Order | PUT |
/orders/{id}/cart |
메뉴 추가 및 변경 |
| Order | DELETE |
/orders/{id}/cart |
메뉴 취소 |
| Order | GET |
/orders/{id}/status |
주문 상태 조회 |
| Review | GET |
/reviews/orders/{id} |
평점 및 리뷰 조회 |
| Review | POST |
/review/products/{code} |
평점 및 리뷰 작성 |
| Category | HTTP Method | URL Path | Description |
|---|---|---|---|
| Product | POST |
/products |
신규 메뉴 등록 |
| Product | PUT |
/products/{code} |
기존 메뉴 수정 |
| Product | DELETE |
/products/{code} |
기존 메뉴 삭제 |
| Order | GET |
/orders |
주문 내역 전체 조회 |
| Order | PUT |
/orders/{id}/status |
주문 상태 변경 |
| Review | GET |
/reviews/orders |
리뷰 모두 조회 |
- Repo
- Article
- Tutorial
- 2023-01-18
- New feature: Sort products by the following variables:
- Date of creation
- Average rating
- Number of likes
- Number of follow-up orders
- New feature: Authorization using JWT
- Middleware for validation of JWT format
- Middleware for role-based access control using the
scopefield in JWT payload
- New feature: Mock authentication that generates a simple JWT access token
- Customer
- Provider
- Refactoring: model and dto
- Input validation (through struct tags) isolated to dto
- Separate
*Viewstructs to select fields to return to users
- New feature: Sort products by the following variables: