// Map the Receiver to a chan<- string for the next Handler(s) // Map the Receiver to a <-chan string for the next Handler(s) func (c *MessageConnection) mapChannels(ctx *macaron.Context) { ctx.Set(reflect.ChanOf(reflect.SendDir, reflect.TypeOf(c.Sender).Elem()), reflect.ValueOf(c.Sender)) ctx.Set(reflect.ChanOf(reflect.RecvDir, reflect.TypeOf(c.Receiver).Elem()), reflect.ValueOf(c.Receiver)) }
// Map the Sender to a chan<- *Message for the next Handler(s) // Map the Receiver to a <-chan *Message for the next Handler(s) func (c *JSONConnection) mapChannels(ctx *macaron.Context) { ctx.Set(reflect.ChanOf(reflect.SendDir, c.Sender.Type().Elem()), c.Sender) ctx.Set(reflect.ChanOf(reflect.RecvDir, c.Receiver.Type().Elem()), c.Receiver) }
// Helper method to map default channels in the context // Map the Error Channel to a <-chan error for the next Handler(s) // Map the Disconnect Channel to a chan<- bool for the next Handler(s) // Map the Done Channel to a <-chan bool for the next Handler(s) func (c *Connection) mapDefaultChannels(ctx *macaron.Context) { ctx.Set(reflect.ChanOf(reflect.RecvDir, reflect.TypeOf(c.Error).Elem()), reflect.ValueOf(c.Error)) ctx.Set(reflect.ChanOf(reflect.SendDir, reflect.TypeOf(c.Disconnect).Elem()), reflect.ValueOf(c.Disconnect)) ctx.Set(reflect.ChanOf(reflect.RecvDir, reflect.TypeOf(c.Done).Elem()), reflect.ValueOf(c.Done)) }