27 lines
646 B
Go
27 lines
646 B
Go
package routes
|
|
|
|
import (
|
|
"bssapp-backend/auth"
|
|
"bssapp-backend/queries"
|
|
"encoding/json"
|
|
"net/http"
|
|
)
|
|
|
|
// GET /api/pricing/products
|
|
func GetProductPricingListHandler(w http.ResponseWriter, r *http.Request) {
|
|
claims, ok := auth.GetClaimsFromContext(r.Context())
|
|
if !ok || claims == nil {
|
|
http.Error(w, "unauthorized", http.StatusUnauthorized)
|
|
return
|
|
}
|
|
|
|
rows, err := queries.GetProductPricingList()
|
|
if err != nil {
|
|
http.Error(w, "Urun fiyatlandirma listesi alinamadi: "+err.Error(), http.StatusInternalServerError)
|
|
return
|
|
}
|
|
|
|
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
|
_ = json.NewEncoder(w).Encode(rows)
|
|
}
|