Displaying a response to user after posting form data

This commit is contained in:
Muyao CHEN
2024-07-01 14:19:38 +02:00
parent 6826634a01
commit 3ad57c754f
4 changed files with 71 additions and 8 deletions

View File

@ -1,9 +1,11 @@
package main
import (
"encoding/gob"
"fmt"
"go-udemy-web-1/internal/config"
"go-udemy-web-1/internal/handlers"
"go-udemy-web-1/internal/models"
"go-udemy-web-1/internal/render"
"log"
"net/http"
@ -21,6 +23,9 @@ var (
// main is the main application function
func main() {
// what am I going to put in the session
gob.Register(models.Reservation{})
// change this to true when in production
app.InProduction = false

View File

@ -27,6 +27,7 @@ func routes(app *config.AppConfig) http.Handler {
mux.Post("/availability-json", handlers.Repo.AvailabilityJSON)
mux.Get("/make-reservation", handlers.Repo.MakeReservation)
mux.Post("/make-reservation", handlers.Repo.PostMakeReservation)
mux.Get("/reservation-summary", handlers.Repo.ReservationSummary)
fileServer := http.FileServer(http.Dir("./static/"))
mux.Handle("/static/*", http.StripPrefix("/static", fileServer))