To implement streaming of binary files without loading entire payloads into memory, use the SkipRequestBodyEncodeDecode and SkipResponseBodyEncodeDecode DSL functions.
Streaming Uploads
Use SkipRequestBodyEncodeDecode in the HTTP definition of a method. This instructs Goa to bypass request encoder/decoder generation and instead provide the underlying io.Reader of the HTTP request to your service.
Important: When using this, any Payload attributes defined must be mapped to HTTP headers or parameters, as the body itself will not be decoded via standard Goa mechanisms.
Streaming Downloads
Use SkipResponseBodyEncodeDecode in the HTTP definition. This allows your service to provide an io.Reader that the generated code will stream directly to the HTTP response body. You should typically map result attributes (like file length) to HTTP headers (like Content-Length) using the Response DSL.
Example design for an upload method:
Method("upload", func() {
Payload(func() {
Attribute("content_type", String, "...")
Attribute("dir", String, "...")
})
HTTP(func() {
POST("/upload/{*dir}")
Header("content_type:Content-Type")
SkipRequestBodyEncodeDecode()
})
})