Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions content/docs/quic/connection.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ Applications can identify which QUIC connection these callbacks are called for b
For example:
```go
tr := quic.Transport{
ConnContext: func(ctx context.Context) context.Context {
ConnContext: func(ctx context.Context, info *quic.ClientInfo) (context.Context, error) {
// In practice, generate an identifier that's unique to this one connection,
// for example by incrementing a counter.
return context.WithValue(ctx, "foo", "bar")
return context.WithValue(ctx, "foo", "bar"), nil
}
}

Expand All @@ -43,6 +43,9 @@ _ = conn.Context()
The context passed to `ConnContext` is closed once the QUIC connection is closed, or if the handshake fails for any reason.
This allows applications to clean up state that might they might have created in the `ConnContext` callback (e.g. by using `context.AfterFunc`).

{{< callout type="info" >}}
By returning an error, `ConnContext` can also be used to reject a connection attempt at a very early stage, before the QUIC handshake is started.
{{< /callout >}}

## Closing a Connection {#closing}

Expand Down