func diffDeploy(w http.ResponseWriter, r *http.Request, t auth.Token) error {
	writer := tsuruIo.NewKeepAliveWriter(w, 30*time.Second, "")
	defer writer.Stop()
	fmt.Fprint(w, "Saving the difference between the old and new code\n")
	appName := r.URL.Query().Get(":appname")
	diff := InputValue(r, "customdata")
	instance, err := app.GetByName(appName)
	if err != nil {
		return &tsuruErrors.HTTP{Code: http.StatusNotFound, Message: err.Error()}
	}
	if t.GetAppName() != app.InternalAppName {
		canDiffDeploy := permission.Check(t, permission.PermAppReadDeploy, contextsForApp(instance)...)
		if !canDiffDeploy {
			return &tsuruErrors.HTTP{Code: http.StatusForbidden, Message: permission.ErrUnauthorized.Error()}
		}
	}
	evt, err := event.GetRunning(appTarget(appName), permission.PermAppDeploy.FullName())
	if err != nil {
		return err
	}
	return evt.SetOtherCustomData(map[string]string{
		"diff": diff,
	})
}
func diffDeploy(w http.ResponseWriter, r *http.Request, t auth.Token) error {
	writer := tsuruIo.NewKeepAliveWriter(w, 30*time.Second, "")
	defer writer.Stop()
	fmt.Fprint(w, "Saving the difference between the old and new code\n")
	appName := r.URL.Query().Get(":appname")
	diff := InputValue(r, "customdata")
	instance, err := app.GetByName(appName)
	if err != nil {
		return &tsuruErrors.HTTP{Code: http.StatusNotFound, Message: err.Error()}
	}
	if t.GetAppName() != app.InternalAppName {
		canDiffDeploy := permission.Check(t, permission.PermAppReadDeploy, contextsForApp(instance)...)
		if !canDiffDeploy {
			return &tsuruErrors.HTTP{Code: http.StatusForbidden, Message: permission.ErrUnauthorized.Error()}
		}
	}
	evt, err := event.GetRunning(appTarget(appName), permission.PermAppDeploy.FullName())
	if err != nil {
		return err
	}
	return evt.SetOtherCustomData(map[string]string{
		"diff": diff,
	})
}
func diffDeploy ( w http . ResponseWriter , r * http . Request , t auth . Token ) error { writer := tsuruIo . NewKeepAliveWriter ( w , 30 * time . Second , " " ) defer writer . Stop ( ) fmt . Fprint ( w , " \n " ) appName := r . URL . Query ( ) . Get ( " " ) diff := InputValue ( r , " " ) instance , err := app . GetByName ( appName ) if err != nil { return & tsuruErrors . HTTP { Code : http . StatusNotFound , Message : err . Error ( ) } } if t . GetAppName ( ) != app . InternalAppName { canDiffDeploy := permission . Check ( t , permission . PermAppReadDeploy , contextsForApp ( instance ) ... ) if ! canDiffDeploy { return & tsuruErrors . HTTP { Code : http . StatusForbidden , Message : permission . ErrUnauthorized . Error ( ) } } } evt , err := event . GetRunning ( appTarget ( appName ) , permission . PermAppDeploy . FullName ( ) ) if err != nil { return err } return evt . SetOtherCustomData ( map [ string ] string { " " : diff , } ) }
// title: deploy diff
// path: /apps/{appname}/diff
// method: POST
// consume: application/x-www-form-urlencoded
// responses:
//   200: OK
//   400: Invalid data
//   403: Forbidden
//   404: Not found
title : deploy diff path : / apps / { appname } / diff method : POST consume : application / x - www - form - urlencoded responses : 200 : OK 400 : Invalid data 403 : Forbidden 404 : Not found