本文整理汇总了Golang中github.com/tsuru/tsuru/app.Platforms函数的典型用法代码示例。如果您正苦于以下问题:Golang Platforms函数的具体用法?Golang Platforms怎么用?Golang Platforms使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Platforms函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: platformList
func platformList(w http.ResponseWriter, r *http.Request, t *auth.Token) error {
u, err := t.User()
if err != nil {
return err
}
rec.Log(u.Email, "platform-list")
platforms, err := app.Platforms()
if err != nil {
return err
}
return json.NewEncoder(w).Encode(platforms)
}
示例2: platformList
func platformList(w http.ResponseWriter, r *http.Request, t auth.Token) error {
u, err := t.User()
if err != nil {
return err
}
rec.Log(u.Email, "platform-list")
platforms, err := app.Platforms(!u.IsAdmin())
if err != nil {
return err
}
w.Header().Set("Content-Type", "application/json")
return json.NewEncoder(w).Encode(platforms)
}
示例3: platformList
// title: platform list
// path: /platforms
// method: GET
// produce: application/json
// responses:
// 200: List platforms
// 204: No content
// 401: Unauthorized
func platformList(w http.ResponseWriter, r *http.Request, t auth.Token) error {
canUsePlat := permission.Check(t, permission.PermPlatformUpdate) ||
permission.Check(t, permission.PermPlatformCreate)
platforms, err := app.Platforms(!canUsePlat)
if err != nil {
return err
}
if len(platforms) == 0 {
w.WriteHeader(http.StatusNoContent)
return nil
}
w.Header().Set("Content-Type", "application/json")
return json.NewEncoder(w).Encode(platforms)
}
示例4: platformList
func platformList(w http.ResponseWriter, r *http.Request, t auth.Token) error {
u, err := t.User()
if err != nil {
return err
}
rec.Log(u.Email, "platform-list")
canUsePlat := permission.Check(t, permission.PermPlatformUpdate) ||
permission.Check(t, permission.PermPlatformCreate)
platforms, err := app.Platforms(!canUsePlat)
if err != nil {
return err
}
w.Header().Set("Content-Type", "application/json")
return json.NewEncoder(w).Encode(platforms)
}