From 59457cc734063f52a521a09e403fa57ff8a291ef Mon Sep 17 00:00:00 2001 From: claudemiro Date: Tue, 13 Jan 2015 13:09:45 -0300 Subject: [PATCH] The channel could be created in the Rest POST Event --- rest.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/rest.go b/rest.go index a071a66..246979a 100644 --- a/rest.go +++ b/rest.go @@ -66,13 +66,7 @@ func PostEvents(w http.ResponseWriter, r *http.Request) { } for _, c := range input.Channels { - channel, err := app.FindChannelByChannelID(c) - - // Channel exists? - if err != nil { - http.Error(w, fmt.Sprintf("Could not find a channel with id %s", c), http.StatusBadRequest) - return - } + channel := app.FindOrCreateChannelByChannelID(c) app.Publish(channel, RawEvent{Event: input.Name, Channel: c, Data: input.Data}, input.SocketID) }