SubjectFilter is a method for the SubjectFilterEngine struct. It takes a context and a pointer to a PermissionSubjectFilterRequest and returns a pointer to a PermissionSubjectFilterResponse and an error.
(ctx context.Context, request *base.PermissionLookupSubjectRequest)
| 59 | // It takes a context and a pointer to a PermissionSubjectFilterRequest |
| 60 | // and returns a pointer to a PermissionSubjectFilterResponse and an error. |
| 61 | func (engine *SubjectFilter) SubjectFilter(ctx context.Context, request *base.PermissionLookupSubjectRequest) (response []string, err error) { |
| 62 | // ReadEntityDefinition method of the SchemaReader interface is used to retrieve the entity's schema definition. |
| 63 | // GetTenantId, GetType and GetSchemaVersion methods are used to provide necessary arguments to ReadEntityDefinition. |
| 64 | var en *base.EntityDefinition |
| 65 | en, _, err = engine.schemaReader.ReadEntityDefinition(ctx, request.GetTenantId(), request.GetEntity().GetType(), request.GetMetadata().GetSchemaVersion()) |
| 66 | if err != nil { |
| 67 | // If an error is encountered while reading the schema definition, return an empty response and the error. |
| 68 | return subjectFilterEmpty(), err |
| 69 | } |
| 70 | |
| 71 | var res []string |
| 72 | |
| 73 | // Call the subjectFilter method of the engine, which returns a function. |
| 74 | // That function is then immediately called with the context to perform the actual subject lookup. |
| 75 | res, err = engine.subjectFilter(ctx, request, en)(ctx) |
| 76 | if err != nil { |
| 77 | // If an error is encountered during the lookup, return an empty response and the error. |
| 78 | return subjectFilterEmpty(), err |
| 79 | } |
| 80 | |
| 81 | // If everything went smoothly, return the lookup result and nil error. |
| 82 | return res, nil |
| 83 | } |
| 84 | |
| 85 | // subjectFilter is a method for the SubjectFilterEngine struct. |
| 86 | // It determines the type of relational reference for the permission field in the request, |
no test coverage detected