| 28 | } |
| 29 | |
| 30 | func (s *Server) AppCreate(c *stdapi.Context) error { |
| 31 | if err := s.hook("AppCreateValidate", c); err != nil { |
| 32 | return err |
| 33 | } |
| 34 | |
| 35 | name := c.Value("name") |
| 36 | |
| 37 | var opts structs.AppCreateOptions |
| 38 | if err := stdapi.UnmarshalOptions(c.Request(), &opts); err != nil { |
| 39 | return err |
| 40 | } |
| 41 | |
| 42 | v, err := s.provider(c).WithContext(c.Context()).AppCreate(name, opts) |
| 43 | if err != nil { |
| 44 | return err |
| 45 | } |
| 46 | |
| 47 | if vs, ok := interface{}(v).(Sortable); ok { |
| 48 | sort.Slice(v, vs.Less) |
| 49 | } |
| 50 | |
| 51 | return c.RenderJSON(v) |
| 52 | } |
| 53 | |
| 54 | func (s *Server) AppDelete(c *stdapi.Context) error { |
| 55 | if err := s.hook("AppDeleteValidate", c); err != nil { |