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-04 14:26:02 +00:00
|
|
|
return mux
|
|
|
|
}
|