Skip to content

Instantly share code, notes, and snippets.

@kaja47
Created December 27, 2012 07:37
Show Gist options
  • Select an option

  • Save kaja47/4386351 to your computer and use it in GitHub Desktop.

Select an option

Save kaja47/4386351 to your computer and use it in GitHub Desktop.
// http://blog.greweb.fr/2012/11/play-framework-enumerator-outputstream/
import java.io.{ BufferedWriter, OutputStreamWriter }
val enumerator = Enumerator.outputStream { os =>
val writer = new BufferedWriter(new OutputStreamWriter(os, encoding), 4096)
template.writeTo(writer)
writer.close()
}
Ok.stream(enumerator andThen Enumerator.eof).withHeaders(
"Content-Type" -> "text/html"
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment