feat(gateway): small adaption for softweng project

Signed-off-by: Klagarge <remi@heredero.ch>
This commit is contained in:
2025-04-15 01:03:57 +02:00
parent 0b57f26688
commit f4d088decd
7 changed files with 100 additions and 116 deletions

View File

@@ -20,17 +20,22 @@ type Command struct {
// @Accept json
// @Produce json
// @Security BasicAuth
// @Param room query string true "Room name" example(Garage)
// @Param device query string true "Device name" example(Door)
// @Param user query string true "User name" example(remi)
// @Param room query string true "Room name" example(Bedroom)
// @Param device query string true "Device name" example(DoorSensor)
// @Param command body main.Command true "Command to publish"
// @Success 200 {object} map[string]string "status:ok"
// @Failure 500 {object} gin.H
// @Router /raclette [post]
func (gh *Gateway) publishCommand(c *gin.Context) error {
// Get the user from the authenticated context
user := c.MustGet(gin.AuthUserKey).(string)
//userid := c.MustGet(gin.AuthUserKey).(string)
// Get room and device from the query parameters
// Get user, room and device from the query parameters
user, ret := c.GetQuery("user")
if !ret {
return errors.New("no user found")
}
room, ret := c.GetQuery("room")
if !ret {
return errors.New(`no room found`)