2024-06-26 15:30:39 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2024-06-27 12:03:43 +00:00
|
|
|
"go-udemy-web-1/pkg/config"
|
2024-06-26 20:06:32 +00:00
|
|
|
"go-udemy-web-1/pkg/handlers"
|
2024-06-27 12:03:43 +00:00
|
|
|
"go-udemy-web-1/pkg/render"
|
|
|
|
"log"
|
2024-06-26 15:30:39 +00:00
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
2024-06-26 15:41:50 +00:00
|
|
|
const portNumber = ":8080"
|
|
|
|
|
|
|
|
// main is the main application function
|
2024-06-26 15:30:39 +00:00
|
|
|
func main() {
|
2024-06-27 12:03:43 +00:00
|
|
|
var app config.AppConfig
|
|
|
|
|
|
|
|
tc, err := render.CreateTemplateCache()
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal("cannot create template cache")
|
|
|
|
}
|
|
|
|
app.TemplateCahce = tc
|
|
|
|
app.UseCache = false
|
|
|
|
|
|
|
|
repo := handlers.NewRepo(&app)
|
|
|
|
handlers.NewHandlers(repo)
|
|
|
|
|
|
|
|
render.NewTemplates(&app)
|
|
|
|
|
|
|
|
http.HandleFunc("/", handlers.Repo.Home)
|
|
|
|
http.HandleFunc("/about", handlers.Repo.About)
|
2024-06-26 15:41:50 +00:00
|
|
|
|
|
|
|
fmt.Printf("Starting application on port %s\n", portNumber)
|
|
|
|
|
|
|
|
_ = http.ListenAndServe(portNumber, nil)
|
2024-06-26 15:30:39 +00:00
|
|
|
}
|