mirror of
https://github.com/diamondburned/arikawa.git
synced 2025-01-07 04:27:18 +00:00
API: WithContext documentation
This commit is contained in:
parent
a0bccd9c35
commit
af682d3f35
|
@ -49,6 +49,8 @@ func NewCustomClient(token string, httpClient *httputil.Client) *Client {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithContext returns a shallow copy of Client with the given context. It's
|
||||||
|
// used for method timeouts and such. This method is thread-safe.
|
||||||
func (c *Client) WithContext(ctx context.Context) *Client {
|
func (c *Client) WithContext(ctx context.Context) *Client {
|
||||||
return &Client{
|
return &Client{
|
||||||
Client: c.Client.WithContext(ctx),
|
Client: c.Client.WithContext(ctx),
|
||||||
|
|
|
@ -76,6 +76,9 @@ func NewFromSession(s *session.Session, store Store) (*State, error) {
|
||||||
return state, state.hookSession()
|
return state, state.hookSession()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithContext returns a shallow copy of State with the context replaced in the
|
||||||
|
// API client. All methods called on the State will use this given context. This
|
||||||
|
// method is thread-safe.
|
||||||
func (s *State) WithContext(ctx context.Context) *State {
|
func (s *State) WithContext(ctx context.Context) *State {
|
||||||
copied := *s
|
copied := *s
|
||||||
copied.Client = copied.Client.WithContext(ctx)
|
copied.Client = copied.Client.WithContext(ctx)
|
||||||
|
|
Loading…
Reference in a new issue