utils

package
v1.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 9, 2021 License: Apache-2.0 Imports: 16 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// GlobalRegistry configures a service registry globally accessible. It defaults to a memory registry. The usage of
	// globals is not encouraged, and this is a workaround until the PR is out of a draft state.
	GlobalRegistry registry.Registry = memory.New(map[string]interface{}{})
)

Functions

func ExtractGranteeID

func ExtractGranteeID(grantee *provider.Grantee) (*userpb.UserId, *grouppb.GroupId)

ExtractGranteeID returns the ID, user or group, set in the GranteeId object

func GetClientIP

func GetClientIP(r *http.Request) (string, error)

GetClientIP retrieves the client IP from incoming requests

func GranteeEqual

func GranteeEqual(u, v *provider.Grantee) bool

GranteeEqual returns whether two grantees have the same field values.

func GroupEqual

func GroupEqual(u, v *grouppb.GroupId) bool

GroupEqual returns whether two groups have the same field values.

func IsEmailValid

func IsEmailValid(e string) bool

IsEmailValid checks whether the provided email has a valid format.

func MarshalProtoV1ToJSON

func MarshalProtoV1ToJSON(m proto.Message) ([]byte, error)

MarshalProtoV1ToJSON marshals a proto V1 message to a JSON byte array TODO: update this once we start using V2 in CS3APIs

func RandString

func RandString(n int) string

RandString is a helper to create tokens.

func ResolvePath

func ResolvePath(path string) (string, error)

ResolvePath converts relative local paths to absolute paths

func ResourceEqual

func ResourceEqual(u, v *provider.ResourceId) bool

ResourceEqual returns whether two resources have the same field values.

func Skip

func Skip(source string, prefixes []string) bool

Skip evaluates whether a source endpoint contains any of the prefixes. i.e: /a/b/c/d/e contains prefix /a/b/c

func TSToTime

func TSToTime(ts *types.Timestamp) time.Time

TSToTime converts a protobuf Timestamp to Go's time.Time.

func TSToUnixNano

func TSToUnixNano(ts *types.Timestamp) uint64

TSToUnixNano converts a protobuf Timestamp to uint64 with nanoseconds resolution.

func ToSnakeCase

func ToSnakeCase(str string) string

ToSnakeCase converts a CamelCase string to a snake_case string.

func UnmarshalJSONToProtoV1

func UnmarshalJSONToProtoV1(b []byte, m proto.Message) error

UnmarshalJSONToProtoV1 decodes a JSON byte array to a specified proto message type TODO: update this once we start using V2 in CS3APIs

func UserEqual

func UserEqual(u, v *userpb.UserId) bool

UserEqual returns whether two users have the same field values.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL