add route for recorder

This commit is contained in:
ginuerzh
2024-09-24 20:20:15 +08:00
parent dd179bc951
commit e22aa91571
26 changed files with 364 additions and 117 deletions
+19 -1
View File
@@ -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
}