mirror of
https://github.com/3ybactuk/marketplace-go-service-project.git
synced 2025-10-30 14:03:45 +03:00
[hw-2] add tests, coverage, benchmarks
This commit is contained in:
@@ -52,7 +52,7 @@ func NewApp(configPath string) (*App, error) {
|
||||
app := &App{
|
||||
config: c,
|
||||
}
|
||||
app.server.Handler = app.bootstrapHandlers()
|
||||
app.server.Handler = app.BootstrapHandlers(app.setupCartService())
|
||||
|
||||
return app, nil
|
||||
}
|
||||
@@ -70,7 +70,7 @@ func (app *App) ListenAndServe() error {
|
||||
return app.server.Serve(l)
|
||||
}
|
||||
|
||||
func (app *App) bootstrapHandlers() http.Handler {
|
||||
func (app *App) setupCartService() *service.CartService {
|
||||
transport := http.DefaultTransport
|
||||
transport = round_trippers.NewLogRoundTripper(transport)
|
||||
transport = round_trippers.NewRetryRoundTripper(transport, productsRetryAttemptsDefault, productsInitialDelaySecDefault)
|
||||
@@ -88,8 +88,11 @@ func (app *App) bootstrapHandlers() http.Handler {
|
||||
|
||||
const userCartCap = 100
|
||||
cartRepository := repository.NewInMemoryRepository(userCartCap)
|
||||
cartService := service.NewCartService(cartRepository, productService)
|
||||
|
||||
return service.NewCartService(cartRepository, productService)
|
||||
}
|
||||
|
||||
func (app *App) BootstrapHandlers(cartService *service.CartService) http.Handler {
|
||||
s := server.NewServer(cartService)
|
||||
|
||||
mx := http.NewServeMux()
|
||||
|
||||
Reference in New Issue
Block a user