diff options
author | Mike Crute <mike@crute.us> | 2021-11-22 18:39:08 -0800 |
---|---|---|
committer | Mike Crute <mike@crute.us> | 2021-11-22 18:39:08 -0800 |
commit | 4f457596a2fa991b5914d4c368697c659db9d1e7 (patch) | |
tree | 3731fab5a7ea1eafb59f6c2770eb74db821f1562 /app | |
parent | 114dbb5ab7952ab66a041c814d5c6a028c8e3039 (diff) | |
download | cloud-identity-broker-4f457596a2fa991b5914d4c368697c659db9d1e7.tar.bz2 cloud-identity-broker-4f457596a2fa991b5914d4c368697c659db9d1e7.tar.xz cloud-identity-broker-4f457596a2fa991b5914d4c368697c659db9d1e7.zip |
Add API index resource
Diffstat (limited to 'app')
-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 | } | ||