本文整理匯總了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)
}