2024-08-04 14:26:02 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/go-chi/chi/v5"
|
|
|
|
"github.com/go-chi/cors"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (app *application) routes() http.Handler {
|
|
|
|
mux := chi.NewRouter()
|
|
|
|
|
|
|
|
mux.Use(cors.Handler(cors.Options{
|
|
|
|
AllowedOrigins: []string{"https://*", "http://*"},
|
|
|
|
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
|
|
|
|
AllowedHeaders: []string{"Accept", "Authorization", "Content-Type", "X-CSRF-Token"},
|
|
|
|
AllowCredentials: false,
|
|
|
|
MaxAge: 300,
|
|
|
|
}))
|
|
|
|
|
2024-08-04 15:34:39 +00:00
|
|
|
mux.Post("/api/payment-intent", app.GetPaymentIntent)
|
2024-08-06 19:35:28 +00:00
|
|
|
mux.Get("/api/widget/{id}", app.GetWidgetByID)
|
2024-08-12 11:49:50 +00:00
|
|
|
mux.Post("/api/create-customer-and-subscribe-to-plan", app.CreateCustomerAndSubscribeToPlan)
|
2024-08-13 11:26:38 +00:00
|
|
|
|
|
|
|
mux.Post("/api/authenticate", app.CreateAuthToken)
|
2024-08-19 19:39:36 +00:00
|
|
|
mux.Post("/api/is-authenticated", app.CheckAuthentication)
|
2024-08-20 11:21:40 +00:00
|
|
|
mux.Route("/api/admin", func(mux chi.Router) {
|
|
|
|
mux.Use(app.Auth)
|
|
|
|
|
2024-08-21 10:54:25 +00:00
|
|
|
// mux.Get("/test", func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
// w.Write([]byte("got in"))
|
|
|
|
// })
|
2024-08-20 11:32:50 +00:00
|
|
|
|
2024-08-20 12:13:35 +00:00
|
|
|
mux.Post("/virtual-terminal-succeeded", app.VirtualTerminalPaymentSucceeded)
|
2024-08-21 21:18:51 +00:00
|
|
|
mux.Post("/all-sales", app.AllSales)
|
2024-08-21 21:27:33 +00:00
|
|
|
mux.Post("/all-subscriptions", app.AllSubscriptions)
|
2024-08-21 21:43:16 +00:00
|
|
|
mux.Post("/get-sale/{id}", app.GetSale)
|
2024-08-22 11:38:51 +00:00
|
|
|
mux.Post("/refund", app.RefundCharge)
|
2024-08-22 19:34:58 +00:00
|
|
|
mux.Post("/cancel-subscription", app.CancelSubscription)
|
2024-08-20 11:21:40 +00:00
|
|
|
})
|
2024-08-20 20:20:37 +00:00
|
|
|
mux.Post("/api/forgot-password", app.SendPasswordResetEmail)
|
2024-08-21 10:54:25 +00:00
|
|
|
mux.Post("/api/reset-password", app.ResetPassword)
|
2024-08-13 11:26:38 +00:00
|
|
|
|
2024-08-04 14:26:02 +00:00
|
|
|
return mux
|
|
|
|
}
|