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
For example, we have a web server, then need to send messages to users if they make some actions on our website. A typical code maybe like this:
func (api*API) handleAction(w http.ResponseWriter, r*http.Request) {
ctx:=r.Context()
// do something with the request's context, like querying the dbdb.getUser(ctx, userid)
// Everything is done and need to notify the user. // However we lost the context for something like tracing, logging or timeout control // since SendMessage doesn't accept `Context`bot.SendMessage(chatIdint64, textstring, opts*SendMessageOpts)
}
Hope I made my point clear 😄
The text was updated successfully, but these errors were encountered:
Hey hey! thanks for opening.
Yes, of course - that makes complete sense. Was wondering when someone would ask for this to be honest 😅
I'd be happy to to add WithContext (or even WithCtx if thats preferred? not sure what the go ecosystem trends to).
Just need to come up with a clean(ish) way of representing that without blindly duplicating the code; shouldn't be too difficult!
I'd really appreciate it if you could try out the branch on your side, and run any tests you might need - this would be a really helpful datapoint so I can make sure everything is working as expected (and is as intuitive as possible!)
For backwards compatibility, maybe add extra methods like
Why need this
For example, we have a web server, then need to send messages to users if they make some actions on our website. A typical code maybe like this:
Hope I made my point clear 😄
The text was updated successfully, but these errors were encountered: