udemy-go-web-2/cmd/web/routes.go

30 lines
748 B
Go
Raw Normal View History

2024-08-03 12:17:39 +02:00
package main
import (
"net/http"
"github.com/go-chi/chi/v5"
)
func (app *application) routes() http.Handler {
mux := chi.NewRouter()
2024-08-10 11:10:27 +02:00
mux.Use(SessionLoad)
2024-08-10 11:10:27 +02:00
mux.Get("/", app.Home)
mux.Get("/virtual-terminal", app.VirtualTerminal)
2024-08-11 12:30:57 +02:00
mux.Post("/virtual-terminal-payment-succeeded", app.VirtualTerminalPaymentSucceeded)
mux.Get("/virtual-terminal-receipt", app.VirtualTerminalReceipt)
2024-08-07 11:56:53 +02:00
mux.Get("/widget/{id}", app.ChargeOnce)
2024-08-11 12:30:57 +02:00
mux.Get("/receipt", app.Receipt)
mux.Post("/payment-succeeded", app.PaymentSucceeded)
2024-08-06 13:29:32 +02:00
2024-08-11 22:08:55 +02:00
mux.Get("/plans/bronze", app.BronzePlan)
2024-08-12 19:23:44 +02:00
mux.Get("/receipt/bronze", app.BronzePlanReceipt)
2024-08-11 22:08:55 +02:00
2024-08-06 13:29:32 +02:00
fileServer := http.FileServer(http.Dir("./static"))
mux.Handle("/static/*", http.StripPrefix("/static", fileServer))
2024-08-03 12:17:39 +02:00
return mux
}