Package io.varhttp
Interface ResponseStream
- All Known Implementing Classes:
- VarResponseStream
public interface ResponseStream
Carrier for http response body stream to be injected into extension point controller methods, to allow the methods to gain access to the response body stream
Example:@Controller(path = "/myPath")public void myControllerMethod(ResponseStream responseStream) { try (BufferedWriter writer = responseStream.getContentWriter("fileName.csv", "text/csv", StandardCharsets.UTF_8)) { writer.append("fileContent"); } }
- 
Method SummaryModifier and TypeMethodDescriptiongetContentWriter(String fileName, String contentType, Charset charset) Get writer that writes to response body in streaming way.default OutputStreamgetOutputStream(String contentType) getOutputStream(String contentType, Charset charset) Get the output-stream of the response.voidvoid
- 
Method Details- 
getContentWriterGet writer that writes to response body in streaming way. This should trigger file download in browser.- Parameters:
- fileName- Name of file for download eg. name.csv
- contentType- File format eg. text/csv for csv files
- charset- Character encoding of the file content eg. StandardCharsets.UTF-8 for UTF-8 encoding
- Returns:
- writer that writes to response body
 
- 
getOutputStreamGet the output-stream of the response. Used to write non-string content.- Parameters:
- contentType- Content format eg. image/png for PNG files
- charset- Character encoding of the file content eg. StandardCharsets.UTF-8 for UTF-8 encoding
- Returns:
- the output stream of the response.
 
- 
getOutputStream
- 
write
- 
write
 
-