niki/patientapp/app.go

35 lines
724 B
Go

package patientapp
import (
"net/http"
"git.gocasts.ir/ebhomengo/niki/patientapp/delivery/http/analytic"
"git.gocasts.ir/ebhomengo/niki/patientapp/repository/database"
)
type Application struct {
Config Config
HTTPServer *http.Server
DB *database.DataBase
Router http.Handler
}
func Setup(config Config, server *http.Server, conn *database.DataBase) Application {
handler := analytic.NewHandler()
router := analytic.NewRouter(handler)
return Application{
Config: config,
HTTPServer: server,
DB: conn,
Router: router,
}
}
func (a *Application) Start() {
srv := &http.Server{Addr: a.HTTPServer.Addr}
server := analytic.NewServer(srv, a.Router)
_ = server.Serve()
}