Documentation ¶
Index ¶
- Constants
- func CleanObject(object interface{}, userType string, action uint) interface{}
- func ExtractFields(object interface{}, userType string, action uint) interface{}
- func ExtractMapObjectsFields(object interface{}, userType string, action uint) interface{}
- func ExtractMultipleObjectsFields(object interface{}, userType string, action uint) interface{}
- func ExtractSingleObjectFields(object interface{}, userType string, action uint) interface{}
Constants ¶
const ( // ActionRead is used when the action is writing ActionRead = 0 // ActionWrite is used when the action is reading ActionWrite = 1 )
Actions
const ( // PermissionRead means it has reading permissions PermissionRead = "r" // PermissionWrite means it has write permissions PermissionWrite = "w" )
Permissions
const PermissionTag = "pex"
PermissionTag is the tag to use in structs to specify the permissions of each field
Variables ¶
This section is empty.
Functions ¶
func CleanObject ¶
CleanObject is a function that receives an object, cleans it by removing the values that the user has not access for that action and returns a pointer to the cleaned object
func ExtractFields ¶
ExtractFields extracts all the fields that a given user have access and returns a JSON interface of that object either its an array, slice or struct. It uses the json tag to get the field name, it it is not defined uses the field name of the struct.
func ExtractMapObjectsFields ¶
ExtractMapObjectsFields extracts all the fields that a given user have access and returns a JSON interface of an array of objects. It uses the json tag to get the field name of each of the objects, it it is not defined uses the field name of the struct.
func ExtractMultipleObjectsFields ¶
ExtractMultipleObjectsFields extracts all the fields that a given user have access and returns a JSON interface of an array of objects. It uses the json tag to get the field name of each of the objects, it it is not defined uses the field name of the struct.
func ExtractSingleObjectFields ¶
ExtractSingleObjectFields extracts all the fields that a given user have access and returns a JSON interface of that object. It uses the json tag to get the field name, it it is not defined uses the field name of the struct.
Types ¶
This section is empty.