40 lines
674 B
Go
40 lines
674 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"go-udemy-web-1/pkg/config"
|
|
"go-udemy-web-1/pkg/handlers"
|
|
"go-udemy-web-1/pkg/render"
|
|
"log"
|
|
"net/http"
|
|
)
|
|
|
|
const portNumber = ":8080"
|
|
|
|
// main is the main application function
|
|
func main() {
|
|
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)
|
|
|
|
fmt.Printf("Starting application on port %s\n", portNumber)
|
|
|
|
srv := &http.Server{
|
|
Addr: portNumber,
|
|
Handler: routes(&app),
|
|
}
|
|
|
|
err = srv.ListenAndServe()
|
|
log.Fatal(err)
|
|
}
|