Files
ziti/controller/handler_common/common.go
T
Paul Lorenz 6fdd5bcda5 Add support for multiple endpoints to services and sync model abstrac… (#53)
* Add support for multiple terminators to services and sync model abstractions with edge

* Add Snapshot to db.Db

* Make API friendly errors

* Add association querying. Consolidate Entity* interfaces
2020-03-19 13:23:16 -04:00

27 lines
712 B
Go

package handler_common
import (
"github.com/michaelquigley/pfxlog"
"github.com/netfoundry/ziti-foundation/channel2"
)
func SendSuccess(request *channel2.Message, ch channel2.Channel, message string) {
SendResult(request, ch, message, true)
}
func SendFailure(request *channel2.Message, ch channel2.Channel, message string) {
SendResult(request, ch, message, false)
}
func SendResult(request *channel2.Message, ch channel2.Channel, message string, success bool) {
log := pfxlog.ContextLogger(ch.Label())
if !success {
log.Errorf("%v error (%s)", ch.LogicalName(), message)
}
response := channel2.NewResult(success, message)
response.ReplyTo(request)
_ = ch.Send(response)
log.Debug("success")
}