This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// domain/product.go | |
package domain | |
type Product struct { | |
Name string | |
Description string | |
Amount int | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (module *Module) Configure(injector *dingo.Injector) { | |
web.BindRoutes(injector, new(Routes)) | |
if os.Getenv("fake") == "true" { | |
injector.Bind(new(service.IOrderService)).To(infrastructure.FakeOrderService{}) | |
} else { | |
injector.Bind(new(service.IOrderService)).To(infrastructure.OrderService{}) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package infrastructure | |
import ( | |
"dashboard/order/domain/entity" | |
) | |
type FakeOrderService struct{} | |
func (fakeOrderService FakeOrderService) GetOrder(id string) (entity.Order, error) { | |
return entity.Order{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"dashboard/api" | |
"flamingo.me/dingo" | |
"flamingo.me/flamingo/v3" | |
"flamingo.me/flamingo/v3/core/requestlogger" | |
) | |
func main() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package api | |
import ( | |
"dashboard/order/domain/service" | |
"dashboard/order/infrastructure" | |
"flamingo.me/dingo" | |
"flamingo.me/flamingo/v3/framework/web" | |
"os" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package api | |
import ( | |
"dashboard/api/interfaces" | |
"flamingo.me/flamingo/v3/framework/web" | |
) | |
type Routes struct { | |
orderController application.OrderController | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (orderController *OrderController) Get(ctx context.Context, req *web.Request) web.Result { | |
orderID, err := req.Query1(orderIDKey) | |
if err != nil { | |
return orderController.responder.ServerError(err) | |
} | |
order, err := orderController.orderService.GetOrder(orderID) | |
if err != nil { | |
return orderController.responder.ServerError(err) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (orderController *OrderController) Inject( | |
responder *web.Responder, | |
orderService service.IOrderService, | |
) { | |
orderController.responder = responder | |
orderController.orderService = orderService | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type ( | |
OrderController struct { | |
responder *web.Responder | |
orderService service.IOrderService | |
} | |
GetOrderResponse struct { | |
Order entity.Order | |
} | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"flamingo.me/dingo" | |
"flamingo.me/flamingo/v3" | |
"flamingo.me/flamingo/v3/core/requestlogger" | |
) | |
func main() { | |
flamingo.App( |