diff options
author | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2017-05-18 11:01:13 +0200 |
---|---|---|
committer | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2017-05-18 11:01:13 +0200 |
commit | 2c9ae6a5a27ae2f2e23495c613e7a53aed8e786c (patch) | |
tree | b23dbe9051c50a7ed8f666ae71c833fd52823770 /lib/apiv1/sdks.go | |
parent | 51da3506a296b7d5d4185b17364f188292136888 (diff) |
Add Cross SDKs support (part 2)
Diffstat (limited to 'lib/apiv1/sdks.go')
-rw-r--r-- | lib/apiv1/sdks.go | 31 |
1 files changed, 31 insertions, 0 deletions
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) +} |