feat(transaction-recurring): #100 generate transactions
Some checks failed
Build Docker Image / Build-Docker-Image (push) Failing after 4m18s

This commit is contained in:
2025-05-29 00:00:19 +02:00
parent 1e7f2878ba
commit 73e7c784a3
6 changed files with 168 additions and 81 deletions

View File

@@ -0,0 +1,24 @@
package middleware
import (
"net/http"
"spend-sparrow/service"
)
func GenerateRecurringTransactions(transactionRecurring service.TransactionRecurring) func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
user := GetUser(r)
if user == nil || r.Method != http.MethodGet {
next.ServeHTTP(w, r)
return
}
go func() {
_ = transactionRecurring.GenerateTransactions(user)
}()
next.ServeHTTP(w, r)
})
}
}