MCPcopy
hub / github.com/apache/casbin / SavePolicyCtx

Method SavePolicyCtx

enforcer_context.go:142–159  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

140}
141
142func (e *ContextEnforcer) SavePolicyCtx(ctx context.Context) error {
143 if e.IsFiltered() {
144 return errors.New("cannot save a filtered policy")
145 }
146 if err := e.adapterCtx.SavePolicyCtx(ctx, e.model); err != nil {
147 return err
148 }
149 if e.watcher != nil {
150 var err error
151 if watcher, ok := e.watcher.(persist.WatcherEx); ok {
152 err = watcher.UpdateForSavePolicy(e.model)
153 } else {
154 err = e.watcher.Update()
155 }
156 return err
157 }
158 return nil
159}
160
161// AddPolicyCtx adds a policy rule to the storage with context.
162func (e *ContextEnforcer) AddPolicyCtx(ctx context.Context, params ...interface{}) (bool, error) {

Callers 1

Calls 4

IsFilteredMethod · 0.65
SavePolicyCtxMethod · 0.65
UpdateForSavePolicyMethod · 0.65
UpdateMethod · 0.65

Tested by 1