You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In frameworks like Flask, you can e.g. start a database transaction before the request starts, and commit/rollback when the request ends. Is there a way to do the same here? I can sort of get the start logic working by making a middleware, but I am not sure how to intercept as a final thing before the response is sent to the user?
Thanks.
The text was updated successfully, but these errors were encountered:
funcbeforeAndAfter(db some.DBConn, next http.Handler) http.Handler {
returnhttp.HandlerFunc(func(w http.ResponseWriter, r*http.Request) {
// Do something before the requestnext.ServeHTTP(w, r)
// Do something after the request
})
}
In your case you may want to use something like httpsnoop to wrap the response writer and add some logic in there that allows you to intercept the content.
Problem statement
In frameworks like Flask, you can e.g. start a database transaction before the request starts, and commit/rollback when the request ends. Is there a way to do the same here? I can sort of get the start logic working by making a middleware, but I am not sure how to intercept as a final thing before the response is sent to the user?
Thanks.
The text was updated successfully, but these errors were encountered: