You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
352 B
22 lines
352 B
package auth
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
type Service struct {
|
|
key struct{ Stuff uint64 }
|
|
}
|
|
|
|
func (s *Service) ContextWithUser(ctx context.Context, id string) context.Context {
|
|
return context.WithValue(ctx, &s.key, id)
|
|
}
|
|
|
|
func (s *Service) GetUser(ctx context.Context) string {
|
|
v := ctx.Value(&s.key)
|
|
if v == nil {
|
|
return ""
|
|
}
|
|
|
|
return v.(string)
|
|
}
|