github.com/cs3org/reva/v2@v2.27.7/internal/http/services/owncloud/ocdav/context.go (about)

     1  package ocdav
     2  
     3  import (
     4  	"context"
     5  
     6  	cs3storage "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
     7  )
     8  
     9  type tokenStatInfoKey struct{}
    10  
    11  // ContextWithTokenStatInfo adds the token stat info to the context
    12  func ContextWithTokenStatInfo(ctx context.Context, info *cs3storage.ResourceInfo) context.Context {
    13  	return context.WithValue(ctx, tokenStatInfoKey{}, info)
    14  }
    15  
    16  // TokenStatInfoFromContext returns the token stat info from the context
    17  func TokenStatInfoFromContext(ctx context.Context) (*cs3storage.ResourceInfo, bool) {
    18  	v, ok := ctx.Value(tokenStatInfoKey{}).(*cs3storage.ResourceInfo)
    19  	return v, ok
    20  }