From 2c9ae6a5a27ae2f2e23495c613e7a53aed8e786c Mon Sep 17 00:00:00 2001 From: Sebastien Douheret Date: Thu, 18 May 2017 11:01:13 +0200 Subject: Add Cross SDKs support (part 2) --- lib/apiv1/sdks.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 lib/apiv1/sdks.go (limited to 'lib/apiv1/sdks.go') diff --git a/lib/apiv1/sdks.go b/lib/apiv1/sdks.go new file mode 100644 index 0000000..5ae2b03 --- /dev/null +++ b/lib/apiv1/sdks.go @@ -0,0 +1,31 @@ +package apiv1 + +import ( + "net/http" + "strconv" + + "github.com/gin-gonic/gin" + "github.com/iotbzh/xds-server/lib/common" +) + +// getSdks returns all SDKs configuration +func (s *APIService) getSdks(c *gin.Context) { + c.JSON(http.StatusOK, s.sdks.GetAll()) +} + +// getSdk returns a specific Sdk configuration +func (s *APIService) getSdk(c *gin.Context) { + id, err := strconv.Atoi(c.Param("id")) + if err != nil { + common.APIError(c, "Invalid id") + return + } + + sdk := s.sdks.Get(id) + if sdk.Profile == "" { + common.APIError(c, "Invalid id") + return + } + + c.JSON(http.StatusOK, sdk) +} -- cgit 1.2.3-korg