1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-17 09:57:01 +00:00

add neffos.Object based on the latest neffos API and update the go.mod for neffos

Former-commit-id: 47836caf61d3c951f1599714a4310bbdef1c87b7
This commit is contained in:
Gerasimos (Makis) Maropoulos
2019-06-03 12:06:18 +03:00
parent 162c1b9cfe
commit e19a519c6e
3 changed files with 21 additions and 8 deletions

View File

@@ -79,8 +79,25 @@ var (
// with the exact same incoming Message's Namespace (and Room if specified)
// except its body which would be the given "body".
Reply = neffos.Reply
// Object marshals the "v" value and returns a Message's Body.
// The "v" serialized value can be customized by implementing a `Marshal() ([]byte, error) ` method,
// otherwise the default one will be used instead ( see `SetDefaultMarshaler` and `SetDefaultUnmarshaler`).
// Errors are pushed to the result, use the object's Marshal method to catch those when necessary.
Object = neffos.Object
)
// SetDefaultMarshaler changes the default json marshaler.
// See `Object` package-level function and `Message.Object` method for more.
func SetDefaultMarshaler(fn func(v interface{}) ([]byte, error)) {
neffos.DefaultMarshaler = fn
}
// SetDefaultUnmarshaler changes the default json unmarshaler.
// See `Object` package-level function and `Message.Object` method for more.
func SetDefaultUnmarshaler(fn func(data []byte, v interface{}) error) {
neffos.DefaultUnmarshaler = fn
}
// Handler returns an Iris handler to be served in a route of an Iris application.
func Handler(s *neffos.Server) context.Handler {
return func(ctx context.Context) {