func parseNewAppData()

in images/controller/cmd/app_publisher/app_publisher.go [250:283]


func parseNewAppData(r *http.Request, oldApp broker.AppConfigSpec) (newAppData, error) {
	resp := newAppData{}

	// Read JSON body
	if r.Header.Get("content-type") != "application/json" {
		return resp, fmt.Errorf("invalid content-type, expected: application/json")
	}

	err := json.NewDecoder(r.Body).Decode(&resp)
	if err != nil {
		return resp, err
	}

	if len(resp.Name) == 0 {
		return resp, fmt.Errorf("missing 'name'")
	}

	if len(resp.DisplayName) == 0 {
		// Default to match name
		resp.DisplayName = resp.Name
	}

	if len(resp.Description) == 0 {
		// Default to old description.
		resp.Description = oldApp.Description
	}

	if len(resp.Icon) == 0 {
		// Default to old icon
		resp.Icon = oldApp.Icon
	}

	return resp, nil
}