Skip to content

Commit

Permalink
Merge pull request #13 from bmf-san/revert-12-fix/logger-interface
Browse files Browse the repository at this point in the history
Revert "Move Logger interface from usecases to interfaces"
  • Loading branch information
bmf-san authored Apr 28, 2022
2 parents 034d0af + 232e49a commit 2c48868
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions app/infrastructure/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"os"
"strings"

"github.com/bmf-san/go-clean-architecture-web-application-boilerplate/app/interfaces"
"github.com/bmf-san/go-clean-architecture-web-application-boilerplate/app/usecases"
)

// Load is load configs from a env file.
func Load(logger interfaces.Logger) {
func Load(logger usecases.Logger) {
filePath := ".env"

f, err := os.Open(filePath)
Expand Down
4 changes: 3 additions & 1 deletion app/infrastructure/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import (
"io"
"log"
"os"

"github.com/bmf-san/go-clean-architecture-web-application-boilerplate/app/usecases"
)

// A Logger belong to the infrastructure layer.
type Logger struct{}

// NewLogger return a Logger.
func NewLogger() *Logger {
func NewLogger() usecases.Logger {
return &Logger{}
}

Expand Down
3 changes: 2 additions & 1 deletion app/infrastructure/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import (
"os"

"github.com/bmf-san/go-clean-architecture-web-application-boilerplate/app/interfaces"
"github.com/bmf-san/go-clean-architecture-web-application-boilerplate/app/usecases"
"github.com/go-chi/chi"
)

// Dispatch is handle routing
func Dispatch(logger interfaces.Logger, sqlHandler interfaces.SQLHandler) {
func Dispatch(logger usecases.Logger, sqlHandler interfaces.SQLHandler) {
userController := interfaces.NewUserController(sqlHandler, logger)
postController := interfaces.NewPostController(sqlHandler, logger)

Expand Down
4 changes: 2 additions & 2 deletions app/interfaces/post_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import (
// A PostController belong to the interface layer.
type PostController struct {
PostInteractor usecases.PostInteractor
Logger Logger
Logger usecases.Logger
}

// NewPostController returns the resource of Posts.
func NewPostController(sqlHandler SQLHandler, logger Logger) *PostController {
func NewPostController(sqlHandler SQLHandler, logger usecases.Logger) *PostController {
return &PostController{
PostInteractor: usecases.PostInteractor{
PostRepository: &PostRepository{
Expand Down
4 changes: 2 additions & 2 deletions app/interfaces/user_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import (
// A UserController belong to the interface layer.
type UserController struct {
UserInteractor usecases.UserInteractor
Logger Logger
Logger usecases.Logger
}

// NewUserController returns the resource of users.
func NewUserController(sqlHandler SQLHandler, logger Logger) *UserController {
func NewUserController(sqlHandler SQLHandler, logger usecases.Logger) *UserController {
return &UserController{
UserInteractor: usecases.UserInteractor{
UserRepository: &UserRepository{
Expand Down
2 changes: 1 addition & 1 deletion app/interfaces/logger.go → app/usecases/logger.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package interfaces
package usecases

// A Logger belong to the usecases layer.
type Logger interface {
Expand Down

0 comments on commit 2c48868

Please sign in to comment.