func (e *Enforcer) Answer(properties []*policy.Rule, credential *policy.Credential) bool {
	var bundle *policy.PolicyBundle
	if bundle = e.Fetch(); bundle == nil {
		return false
	}
	resource, err := utils.NewResource(properties, credential)
	if err != nil {
		log.Printf("Error assembling the request into a Policy Resource: %v", err)
		return false
	}
	valid, accept, allow := bundle.Match(resource, e.resource, time.Now(), e.Location)
	log.Printf("Request resolved as: valid=%v,accepted=%v,allowed=%v", valid, accept, allow)
	return valid && (!accept || allow)
}
Implementation of the Request Level Answer API
Answer is the implementation of the Enforcer Answer API. It takes an access request for a
given resource and evaluates it against the existing policies.
package enforcer
import (
	"log"
	"time"
	"github.com/padmeio/padme/enforcer/plugins"
	"github.com/padmeio/padme/enforcer/store"
	"github.com/padmeio/padme/enforcer/utils"
	"github.com/padmeio/padme/policy"
)
type loadedPlugin struct {
	plugins.Plugin
	enabled bool
}
type Enforcer struct {
	Location *policy.Location
	Store store.PolicyRepository
	Handlers map[string]PolicyEventHandler
	RegisteredPlugins map[string]*loadedPlugin
	resource *policy.Resource
}
func NewEnforcer(store store.PolicyRepository, location *policy.Location, credentials *policy.Credential) Enforcer {
	localAddresses, err := utils.LocalAddresses()
	if err != nil {
		log.Fatalf("error reading local addresses: %v", err)
	}
	var resource *policy.Resource
	resource, err = utils.AddressesToResource(localAddresses, credentials)
	if err != nil {
		log.Fatalf("error building enforcer resource: %v", err)
	}
	return Enforcer{
		Location:          location,
		Store:             store,
		Handlers:          make(map[string]PolicyEventHandler),
		RegisteredPlugins: make(map[string]*loadedPlugin),
		resource:          resource,
	}
}