Files
bssapp/svc/routes/todaycurrencyv3.go
2026-02-11 17:46:22 +03:00

31 lines
686 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package routes
import (
"bssapp-backend/queries"
"database/sql"
"encoding/json"
"fmt"
"net/http"
)
// ✅ Handler artık parametre alıyor
func GetTodayCurrencyV3Handler(mssql *sql.DB) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
code := r.URL.Query().Get("code")
if code == "" {
http.Error(w, "Eksik parametre: code", http.StatusBadRequest)
return
}
currency, err := queries.GetTodayCurrencyV3(mssql, code) // 👈 MSSQL
if err != nil {
http.Error(w, fmt.Sprintf("Kur bulunamadı: %v", err), http.StatusNotFound)
return
}
w.Header().Set("Content-Type", "application/json")
_ = json.NewEncoder(w).Encode(currency)
}
}