📩
postfix-policy-server
  • 👋Welcome
  • API
    • 🚀Server
    • 📋ServerOpt
    • 📐Handler
    • 🗃️PolicySet
    • 📣Postfix(Text)Resp
  • Code Examples
    • 💡Policy to JSON echo server
Powered by GitBook
On this page
  1. API

Handler

Handler is the interface for you to process the policy data

PreviousServerOptNextPolicySet

Last updated 3 years ago

The Handler interface of the pps package is very simple and consists only of one method. When starting a new policy service on your instance, the Run() method requires a type that satisfies the Handler interface.

This provides and easy way for your program to handle the dataset provided by the Postfix server. Once the dataset has been provided and processed by the pps server, it will hand the to the Handle() method of the Handler interface type you provided. All it expects back is a proper response of the type that it can write back to Postfix. What you do with the in your Handle() method is totally up to you.

type Handler interface {
	Handle(*PolicySet) PostfixResp
}
// Empty struct to act the Handler interface
type Hi struct {
	r PostfixResp
}

// Handle is the function required by the Handler Interface
func (h Hi) Handle(*pps.PolicySet) pps.PostfixResp {
	if h.r == "" {
		h.r = pps.RespDunno
	}
	return h.r
}
📐
Server
PolicySet
PostfixResp
PolicySet