add route for recorder
This commit is contained in:
+19
-1
@@ -1,6 +1,9 @@
|
||||
package ctx
|
||||
|
||||
import "context"
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
)
|
||||
|
||||
// clientAddrKey saves the client address.
|
||||
type clientAddrKey struct{}
|
||||
@@ -74,3 +77,18 @@ func ClientIDFromContext(ctx context.Context) ClientID {
|
||||
v, _ := ctx.Value(keyClientID).(ClientID)
|
||||
return v
|
||||
}
|
||||
|
||||
type bufferKey struct{}
|
||||
|
||||
var (
|
||||
keyBuffer = &bufferKey{}
|
||||
)
|
||||
|
||||
func ContextWithBuffer(ctx context.Context, buffer *bytes.Buffer) context.Context {
|
||||
return context.WithValue(ctx, keyBuffer, buffer)
|
||||
}
|
||||
|
||||
func BufferFromContext(ctx context.Context) *bytes.Buffer {
|
||||
v, _ := ctx.Value(keyBuffer).(*bytes.Buffer)
|
||||
return v
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user