func serviceInstanceProxy(w http.ResponseWriter, r *http.Request, t auth.Token) (err error) {
	serviceName := r.URL.Query().Get(":service")
	instanceName := r.URL.Query().Get(":instance")
	serviceInstance, err := getServiceInstanceOrError(serviceName, instanceName)
	if err != nil {
		return err
	}
	allowed := permission.Check(t, permission.PermServiceInstanceUpdateProxy,
		contextsForServiceInstance(serviceInstance, serviceName)...,
	)
	if !allowed {
		return permission.ErrUnauthorized
	}
	path := r.URL.Query().Get("callback")
	var evt *event.Event
	if r.Method != http.MethodGet && r.Method != http.MethodHead {
		evt, err = event.New(&event.Opts{
			Target: serviceInstanceTarget(serviceName, instanceName),
			Kind:   permission.PermServiceInstanceUpdateProxy,
			Owner:  t,
			CustomData: append(event.FormToCustomData(InputFields(r)), map[string]interface{}{
				"name":  "method",
				"value": r.Method,
			}),
			Allowed: event.Allowed(permission.PermServiceInstanceReadEvents,
				contextsForServiceInstance(serviceInstance, serviceName)...),
		})
		if err != nil {
			return err
		}
		defer func() { evt.Done(err) }()
	}
	return service.ProxyInstance(serviceInstance, path, evt, requestIDHeader(r), w, r)
}
func serviceInstanceProxy(w http.ResponseWriter, r *http.Request, t auth.Token) (err error) {
	serviceName := r.URL.Query().Get(":service")
	instanceName := r.URL.Query().Get(":instance")
	serviceInstance, err := getServiceInstanceOrError(serviceName, instanceName)
	if err != nil {
		return err
	}
	allowed := permission.Check(t, permission.PermServiceInstanceUpdateProxy,
		contextsForServiceInstance(serviceInstance, serviceName)...,
	)
	if !allowed {
		return permission.ErrUnauthorized
	}
	path := r.URL.Query().Get("callback")
	var evt *event.Event
	if r.Method != http.MethodGet && r.Method != http.MethodHead {
		evt, err = event.New(&event.Opts{
			Target: serviceInstanceTarget(serviceName, instanceName),
			Kind:   permission.PermServiceInstanceUpdateProxy,
			Owner:  t,
			CustomData: append(event.FormToCustomData(InputFields(r)), map[string]interface{}{
				"name":  "method",
				"value": r.Method,
			}),
			Allowed: event.Allowed(permission.PermServiceInstanceReadEvents,
				contextsForServiceInstance(serviceInstance, serviceName)...),
		})
		if err != nil {
			return err
		}
		defer func() { evt.Done(err) }()
	}
	return service.ProxyInstance(serviceInstance, path, evt, requestIDHeader(r), w, r)
}
func serviceInstanceProxy ( w http . ResponseWriter , r * http . Request , t auth . Token ) ( err error ) { serviceName := r . URL . Query ( ) . Get ( " " ) instanceName := r . URL . Query ( ) . Get ( " " ) serviceInstance , err := getServiceInstanceOrError ( serviceName , instanceName ) if err != nil { return err } allowed := permission . Check ( t , permission . PermServiceInstanceUpdateProxy , contextsForServiceInstance ( serviceInstance , serviceName ) ... , ) if ! allowed { return permission . ErrUnauthorized } path := r . URL . Query ( ) . Get ( " " ) var evt * event . Event if r . Method != http . MethodGet && r . Method != http . MethodHead { evt , err = event . New ( & event . Opts { Target : serviceInstanceTarget ( serviceName , instanceName ) , Kind : permission . PermServiceInstanceUpdateProxy , Owner : t , CustomData : append ( event . FormToCustomData ( InputFields ( r ) ) , map [ string ] interface { } { " " : " " , " " : r . Method , } ) , Allowed : event . Allowed ( permission . PermServiceInstanceReadEvents , contextsForServiceInstance ( serviceInstance , serviceName ) ... ) , } ) if err != nil { return err } defer func ( ) { evt . Done ( err ) } ( ) } return service . ProxyInstance ( serviceInstance , path , evt , requestIDHeader ( r ) , w , r ) }
// title: service instance proxy
// path: /services/{service}/proxy/{instance}
// method: "*"
// responses:
//   401: Unauthorized
//   404: Instance not found
title : service instance proxy path : / services / { service } / proxy / { instance } method : * responses : 401 : Unauthorized 404 : Instance not found