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