Skip to content

feat: add streaming multipart file-server playground - #71

Merged
fredbi merged 5 commits into
go-swagger:masterfrom
fpawel:feature/streaming-multipart-file-server
Jul 27, 2026
Merged

feat: add streaming multipart file-server playground#71
fredbi merged 5 commits into
go-swagger:masterfrom
fpawel:feature/streaming-multipart-file-server

Conversation

@fpawel

@fpawel fpawel commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Purpose

Experimental integration playground for go-openapi/runtime#507.

This manually adapts the generated file-server binder to demonstrate the
intended future go-swagger code generation and handler ownership model.

It is not intended for merge until the runtime API and code generation approach
are settled.

What it demonstrates

  • the handler receives a streamed file before the client completes the multipart request body;
  • file payloads are read directly from the request body;
  • the binder transfers ownership of MultipartFormStream to the handler;
  • the handler explicitly chooses between Drain() and Close();
  • an external http.MaxBytesHandler limit propagates through the streamed reader and results in HTTP 413.

Black-box test

The integration test uses a real httptest.Server and an io.Pipe request body.

The client sends the multipart headers and the first file bytes, then pauses.
The test verifies that the generated router, binder and handler have already
received and started reading the file before the client resumes and finishes
the multipart body.

The generated binder is currently adapted manually to represent the expected
future code generation.

Comment thread file-server/restapi/operations/uploads/upload_file_parameters.go Outdated
Comment thread file-server/restapi/operations/uploads/upload_file_parameters.go Outdated
Comment thread file-server/restapi/operations/uploads/upload_file_parameters.go Outdated
Keep generated streaming binding limited to constructing and passing MultipartFormStream.

Let the handler own multipart traversal, required-file checks and application-specific validation, and demonstrate discovered field and file state in the black-box streaming test.

Signed-off-by: Филимоненков Павел Анатольевич <p.filimonenkov@office.st-falcon.ru>
@fpawel
fpawel marked this pull request as ready for review July 24, 2026 16:06

@fredbi fredbi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep that’s the right shape as far as i can tell.
This PR may move to a distinct version of the example (or perhaps two operations showing the 2 operating modes not sure yet) after we are able to generate the proper bindings from go-swagger.

Prototype is convincing.

@fredbi
fredbi merged commit 4982312 into go-swagger:master Jul 27, 2026
15 of 16 checks passed
@fredbi

fredbi commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

I think you made it through with the full round-trip: openapi lib -> go swagger -> examples

excellent feature imho. Thanks a lot @fpawel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants