Skip to content

Instantly share code, notes, and snippets.

@johnson86tw
Last active October 24, 2020 15:59
Show Gist options
  • Save johnson86tw/764766edff9c042fb62e19c752398597 to your computer and use it in GitHub Desktop.
Save johnson86tw/764766edff9c042fb62e19c752398597 to your computer and use it in GitHub Desktop.
// web framework
app := echo.New()
// middleware
app.Use(middleware.Logger())
app.Use(middleware.Recover())
// service
accountRepo := accountRepo.NewRepository(pgConn)
as := accountService.NewAccountService(accountRepo)
userURLRepo := userURLRepo.NewRepository(pgConn)
us := userURLService.NewUserURLService(userURLRepo)
redirectRepo := redirectRepo.NewRepository(pgConn)
rs := redirectService.NewRedirectService(redirectRepo, userURLRepo)
// api
api.NewAccountHandler(app, as, j)
api.NewRedirectHandler(app, rs)
// auth
auth := app.Group("/auth")
auth.Use(j.AuthRequired)
{
api.NewUserURLHandler(auth, us)
}
app.Logger.Fatal(app.Start(serverAddr))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment