ilk
This commit is contained in:
30
svc/routes/todaycurrencyv3.go
Normal file
30
svc/routes/todaycurrencyv3.go
Normal file
@@ -0,0 +1,30 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user