LoadModel reloads the model from the model CONF file. Because the policy is attached to a model, so the policy is invalidated and needs to be reloaded by calling LoadPolicy().
()
| 204 | // LoadModel reloads the model from the model CONF file. |
| 205 | // Because the policy is attached to a model, so the policy is invalidated and needs to be reloaded by calling LoadPolicy(). |
| 206 | func (e *Enforcer) LoadModel() error { |
| 207 | var err error |
| 208 | e.model, err = model.NewModelFromFile(e.modelPath) |
| 209 | if err != nil { |
| 210 | return err |
| 211 | } |
| 212 | |
| 213 | e.model.PrintModel() |
| 214 | e.fm = model.LoadFunctionMap() |
| 215 | |
| 216 | e.initialize() |
| 217 | |
| 218 | return nil |
| 219 | } |
| 220 | |
| 221 | // GetModel gets the current model. |
| 222 | func (e *Enforcer) GetModel() model.Model { |