Skip to content

How to handle the case of multiple controllers #1

Description

@err-him

Hi,

Not an Issue but Question

Thanks for setting up the repo, it actually clears the picture of clean code practices. I have one doubt what if there are multiple controllers suppose in controller folder there are multiple files regarding users, books, clients etc, so In order to setup DB connection do we need to have base Handler in each and every file?

`// BaseHandler will hold everything that controller needs
type BaseHandler struct {
db *sql.DB
}

// NewBaseHandler returns a new BaseHandler
func NewBaseHandler(db *sql.DB) *BaseHandler {
return &BaseHandler{
db: db,
}
}`
if yes? won't be it too redundant to using the same piece of code again and again?
Once again Thanks for the Repo, it cleared my too many doubts already.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions