diff --git a/db/get-db.http b/db/get-db.http index f4acd9e..79a7889 100644 --- a/db/get-db.http +++ b/db/get-db.http @@ -18,4 +18,3 @@ Authorization: Basic {{username}} {{password}} ### GET battery status of all devices GET {{host}}/api/v1/battery -Authorization: Basic {{username}} {{password}} diff --git a/db/src/rest/rest.go b/db/src/rest/rest.go index 67d5654..a921ab9 100644 --- a/db/src/rest/rest.go +++ b/db/src/rest/rest.go @@ -63,6 +63,10 @@ func (g *RestGateway) setupRoutes() { g.engine.Use(cors.New(corsConfig)) v1 := g.engine.Group("/api/v1") + + // Public endpoints (no auth required) + v1.GET("/battery", g.getBattery) + if g.username != "" && g.password != "" { v1.Use(gin.BasicAuth(gin.Accounts{ g.username: g.password, @@ -73,7 +77,6 @@ func (g *RestGateway) setupRoutes() { v1.GET("/rooms", g.getRooms) v1.GET("/rooms/:room-id/current", g.getRoomCurrent) v1.GET("/rooms/:room-id/history", g.getRoomHistory) - v1.GET("/battery", g.getBattery) } g.engine.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))