Centralizing error handling to a helpers package
This commit is contained in:
		@ -5,10 +5,12 @@ import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"go-udemy-web-1/internal/config"
 | 
			
		||||
	"go-udemy-web-1/internal/handlers"
 | 
			
		||||
	"go-udemy-web-1/internal/helpers"
 | 
			
		||||
	"go-udemy-web-1/internal/models"
 | 
			
		||||
	"go-udemy-web-1/internal/render"
 | 
			
		||||
	"log"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"os"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"github.com/alexedwards/scs/v2"
 | 
			
		||||
@ -17,8 +19,10 @@ import (
 | 
			
		||||
const portNumber = ":8080"
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	app     config.AppConfig
 | 
			
		||||
	session *scs.SessionManager
 | 
			
		||||
	app      config.AppConfig
 | 
			
		||||
	session  *scs.SessionManager
 | 
			
		||||
	infoLog  *log.Logger
 | 
			
		||||
	errorLog *log.Logger
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// main is the main application function
 | 
			
		||||
@ -61,8 +65,15 @@ func run() error {
 | 
			
		||||
	app.TemplateCahce = tc
 | 
			
		||||
	app.UseCache = false
 | 
			
		||||
 | 
			
		||||
	infoLog = log.New(os.Stdout, "INFO\t", log.Ldate|log.Ltime)
 | 
			
		||||
	app.InfoLog = infoLog
 | 
			
		||||
 | 
			
		||||
	errorLog = log.New(os.Stdout, "ERROR\t", log.Ldate|log.Ltime|log.Lshortfile)
 | 
			
		||||
	app.ErrorLog = errorLog
 | 
			
		||||
 | 
			
		||||
	repo := handlers.NewRepo(&app)
 | 
			
		||||
	handlers.NewHandlers(repo)
 | 
			
		||||
	helpers.NewHelpers(&app)
 | 
			
		||||
 | 
			
		||||
	render.NewTemplates(&app)
 | 
			
		||||
	return nil
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user