diff options
Diffstat (limited to 'app/controllers/api.go')
-rw-r--r-- | app/controllers/api.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/app/controllers/api.go b/app/controllers/api.go index 7beaa4c..5ee6591 100644 --- a/app/controllers/api.go +++ b/app/controllers/api.go | |||
@@ -1,6 +1,32 @@ | |||
1 | package controllers | 1 | package controllers |
2 | 2 | ||
3 | import ( | ||
4 | "net/http" | ||
5 | |||
6 | "code.crute.us/mcrute/cloud-identity-broker/app/middleware" | ||
7 | |||
8 | glecho "code.crute.us/mcrute/golib/echo" | ||
9 | "github.com/labstack/echo/v4" | ||
10 | ) | ||
11 | |||
3 | const ( | 12 | const ( |
4 | contentTypeV1 = "application/vnd.broker.v1+json" // Original type | 13 | contentTypeV1 = "application/vnd.broker.v1+json" // Original type |
5 | contentTypeV2 = "application/vnd.broker.v2+json" // Start of migration to multi-cloud | 14 | contentTypeV2 = "application/vnd.broker.v2+json" // Start of migration to multi-cloud |
6 | ) | 15 | ) |
16 | |||
17 | func APIIndexHandler(c echo.Context) error { | ||
18 | p, err := middleware.GetAuthorizedPrincipal(c) | ||
19 | if err != nil { | ||
20 | return echo.ErrUnauthorized | ||
21 | } | ||
22 | |||
23 | out := map[string]string{ | ||
24 | "accounts": glecho.URLFor(c, "/api/account").String(), | ||
25 | } | ||
26 | |||
27 | if p.IsAdmin { | ||
28 | out["users"] = glecho.URLFor(c, "/api/user").String() | ||
29 | } | ||
30 | |||
31 | return c.JSON(http.StatusOK, out) | ||
32 | } | ||