Change `/channels` API
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
This commit is contained in:
parent
52f0017be5
commit
57a4535bc4
|
@ -58,8 +58,11 @@ func CreateChannel(ctx *iris.Context) {
|
|||
c.Id = uuid.String()
|
||||
|
||||
// Insert reference to DeviceId
|
||||
did := ctx.Param("device_id")
|
||||
c.Device = did
|
||||
if c.Device = nil {
|
||||
ctx.JSON(iris.StatusBadRequest, iris.Map{"response": "No device ID in request body"})
|
||||
}
|
||||
|
||||
// TODO Check if Device ID is valid (in database)
|
||||
|
||||
// Timestamp
|
||||
t := time.Now().UTC().Format(time.RFC3339)
|
||||
|
|
|
@ -15,7 +15,7 @@ import (
|
|||
type (
|
||||
Channel struct {
|
||||
Id string `json:"id"`
|
||||
Device string `json:"device"`
|
||||
Device string `json:"device,omitempty"`
|
||||
Created string `json:"created"`
|
||||
Updated string `json:"updated"`
|
||||
|
||||
|
|
|
@ -59,11 +59,11 @@ func registerRoutes() {
|
|||
iris.Delete("/devices/:device_id", controllers.DeleteDevice)
|
||||
|
||||
// CHANNELS
|
||||
iris.Post("/devices/:device_id/channels", controllers.CreateChannel)
|
||||
iris.Get("/devices/:device_id/channels", controllers.GetChannels)
|
||||
iris.Post("/channels", controllers.CreateChannel)
|
||||
iris.Get("/channels", controllers.GetChannels)
|
||||
|
||||
iris.Get("/devices/:device_id/channels/:channel_id", controllers.GetChannel)
|
||||
iris.Put("/devices/:device_id/channels/:channel_id", controllers.UpdateChannel)
|
||||
iris.Get("/channels/:channel_id", controllers.GetChannel)
|
||||
iris.Put("/channels/:channel_id", controllers.UpdateChannel)
|
||||
|
||||
iris.Delete("/devices/:device_id/channels/:channel_id", controllers.DeleteChannel)
|
||||
iris.Delete("/channels/:channel_id", controllers.DeleteChannel)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue