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

50 lines
1.3 KiB
Go
Raw Normal View History

2024-08-03 10:17:39 +00:00
package main
import (
"net/http"
"github.com/go-chi/chi/v5"
)
func (app *application) routes() http.Handler {
mux := chi.NewRouter()
2024-08-10 09:10:27 +00:00
mux.Use(SessionLoad)
2024-08-10 09:10:27 +00:00
mux.Get("/", app.Home)
2024-08-26 19:22:48 +00:00
mux.Get("/ws", app.WsEndPoint)
mux.Route("/admin", func(mux chi.Router) {
mux.Use(app.Auth)
mux.Get("/virtual-terminal", app.VirtualTerminal)
2024-08-21 19:49:08 +00:00
mux.Get("/all-sales", app.AllSales)
mux.Get("/all-subscriptions", app.AllSubscriptions)
2024-08-21 21:43:16 +00:00
mux.Get("/sales/{id}", app.ShowSale)
2024-08-22 07:56:14 +00:00
mux.Get("/subscriptions/{id}", app.ShowSubscriptions)
mux.Get("/all-users", app.AllUsers)
mux.Get("/all-users/{id}", app.OneUser)
})
// mux.Post("/virtual-terminal-payment-succeeded", app.VirtualTerminalPaymentSucceeded)
// mux.Get("/virtual-terminal-receipt", app.VirtualTerminalReceipt)
2024-08-11 10:30:57 +00:00
2024-08-07 09:56:53 +00:00
mux.Get("/widget/{id}", app.ChargeOnce)
2024-08-11 10:30:57 +00:00
mux.Get("/receipt", app.Receipt)
mux.Post("/payment-succeeded", app.PaymentSucceeded)
2024-08-06 11:29:32 +00:00
2024-08-11 20:08:55 +00:00
mux.Get("/plans/bronze", app.BronzePlan)
2024-08-12 17:23:44 +00:00
mux.Get("/receipt/bronze", app.BronzePlanReceipt)
2024-08-11 20:08:55 +00:00
2024-08-12 19:38:12 +00:00
// auth routes
mux.Get("/login", app.LoginPage)
mux.Post("/login", app.PostLoginPage)
mux.Get("/logout", app.Logout)
2024-08-20 20:06:04 +00:00
mux.Get("/forgot-password", app.ForgotPassword)
mux.Get("/reset-password", app.ShowResetPassword)
2024-08-12 19:38:12 +00:00
2024-08-06 11:29:32 +00:00
fileServer := http.FileServer(http.Dir("./static"))
mux.Handle("/static/*", http.StripPrefix("/static", fileServer))
2024-08-03 10:17:39 +00:00
return mux
}