api/platform.go
func platformUpdate(w http.ResponseWriter, r *http.Request, t auth.Token) (err error) {
	name := r.URL.Query().Get(":name")
	file, _, _ := r.FormFile("dockerfile_content")
	if file != nil {
		defer file.Close()
	}
	args := make(map[string]string)
	for key, values := range r.Form {
		args[key] = values[0]
	}
	canUpdatePlatform := permission.Check(t, permission.PermPlatformUpdate)
	if !canUpdatePlatform {
		return permission.ErrUnauthorized
	}
	w.Header().Set("Content-Type", "application/x-json-stream")
	keepAliveWriter := io.NewKeepAliveWriter(w, 30*time.Second, "")
	defer keepAliveWriter.Stop()
	writer := &io.SimpleJsonMessageEncoderWriter{Encoder: json.NewEncoder(keepAliveWriter)}
	evt, err := event.New(&event.Opts{
		Target:     event.Target{Type: event.TargetTypePlatform, Value: name},
		Kind:       permission.PermPlatformUpdate,
		Owner:      t,
		CustomData: event.FormToCustomData(InputFields(r)),
		Allowed:    event.Allowed(permission.PermPlatformReadEvents),
	})
	if err != nil {
		return err
	}
	defer func() { evt.Done(err) }()
	evt.SetLogWriter(writer)
	ctx, cancel := evt.CancelableContext(context.Background())
	err = servicemanager.Platform.Update(appTypes.PlatformOptions{
		Name:   name,
		Args:   args,
		Input:  file,
		Output: evt,
		Ctx:    ctx,
	})
	cancel()
	if err == appTypes.ErrPlatformNotFound {
		return &tErrors.HTTP{Code: http.StatusNotFound, Message: err.Error()}
	}
	if err != nil {
		return err
	}
	writer.Write([]byte("Platform successfully updated!\n"))
	return nil
}
func platformUpdate(w http.ResponseWriter, r *http.Request, t auth.Token) (err error) {
	name := r.URL.Query().Get(":name")
	file, _, _ := r.FormFile("dockerfile_content")
	if file != nil {
		defer file.Close()
	}
	args := make(map[string]string)
	for key, values := range r.Form {
		args[key] = values[0]
	}
	canUpdatePlatform := permission.Check(t, permission.PermPlatformUpdate)
	if !canUpdatePlatform {
		return permission.ErrUnauthorized
	}
	w.Header().Set("Content-Type", "application/x-json-stream")
	keepAliveWriter := io.NewKeepAliveWriter(w, 30*time.Second, "")
	defer keepAliveWriter.Stop()
	writer := &io.SimpleJsonMessageEncoderWriter{Encoder: json.NewEncoder(keepAliveWriter)}
	evt, err := event.New(&event.Opts{
		Target:     event.Target{Type: event.TargetTypePlatform, Value: name},
		Kind:       permission.PermPlatformUpdate,
		Owner:      t,
		CustomData: event.FormToCustomData(InputFields(r)),
		Allowed:    event.Allowed(permission.PermPlatformReadEvents),
	})
	if err != nil {
		return err
	}
	defer func() { evt.Done(err) }()
	evt.SetLogWriter(writer)
	ctx, cancel := evt.CancelableContext(context.Background())
	err = servicemanager.Platform.Update(appTypes.PlatformOptions{
		Name:   name,
		Args:   args,
		Input:  file,
		Output: evt,
		Ctx:    ctx,
	})
	cancel()
	if err == appTypes.ErrPlatformNotFound {
		return &tErrors.HTTP{Code: http.StatusNotFound, Message: err.Error()}
	}
	if err != nil {
		return err
	}
	writer.Write([]byte("Platform successfully updated!\n"))
	return nil
}
// title: update platform
// path: /platforms/{name}
// method: PUT
// produce: application/x-json-stream
// responses:
//   200: Platform updated
//   401: Unauthorized
//   404: Not found