Beispiel #1
0
func (s *CliJobResponse) SuccessWithWrite(t jobs.JobResponseSuccess, flush, structured bool) io.Writer {
	s.Success(t)
	if s.Gather {
		if structured {
			panic("Client does not support receiving streaming structured data.")
		}
		buf := bytes.Buffer{}
		s.Data = &buf
		return &buf
	}
	return utils.NewWriteFlusher(s.Output)
}
Beispiel #2
0
func (s *ClientResponse) SuccessWithWrite(t ResponseSuccess, flush, structured bool) io.Writer {
	s.Success(t)
	if s.Gather {
		if structured {
			s.Error = errors.New("jobs: Client does not support receiving streaming structured data")
			return ioutil.Discard
		}
		buf := bytes.Buffer{}
		s.Data = &buf
		return &buf
	}
	return utils.NewWriteFlusher(s.Output)
}
Beispiel #3
0
func (s *httpJobResponse) SuccessWithWrite(t jobs.JobResponseSuccess, flush, structured bool) io.Writer {
	if structured {
		s.response.Header().Add("Content-Type", "application/json")
	} else {
		s.response.Header().Add("Content-Type", "text/plain")
	}
	s.success(t, !s.skipStreaming, false)
	var w io.Writer
	if s.skipStreaming {
		w = ioutil.Discard
	} else if flush {
		w = utils.NewWriteFlusher(s.response)
	} else {
		w = s.response
	}
	return w
}