Request body middleware
See original GitHub issueI wanted to make simple REST API with oak but noticed that there is no body
field on Request
, or worse any way to access underlying ServerRequest
’s body. I guess body parsing middleware is missing.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
How to read the request body in ASP.NET Core Middleware?
Right-click on your project in Solution Explorer and click “Add New Item”. In the search box type “Middleware” and you will see Middleware...
Read more >Reading request body in middleware for .Net 5 - Stack Overflow
Usually Request.Body does not support rewinding, so it can only be read once. A temp workaround is to pull out the body right...
Read more >Request and Response operations in ASP.NET Core
Suppose the goal is to create a middleware that reads the entire request body as a list of strings, splitting on new lines....
Read more >Express body-parser middleware
Returns middleware that parses all bodies as a string and only looks at requests where the Content-Type header matches the type option. This...
Read more >Read request body multiple times #40635 - dotnet/aspnetcore
Request.EnableBuffering(); // Call the next delegate/middleware in the pipeline await next(context); ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Closed in 81326b2a1aa292cd1de837841fcb6b6bdfbf4c73
I took a little bit different direction. Instead of a seperate middleware,
context.request.body()
returns aPromise
that will resolve with a parsed body for JSON, URL encoded forms, or text. So basic use cases should just work.I would like to automagically deal with multi-part forms, but that might be best with seperate middleware, versus baking that into the response. The original
net
server request is also available publically now which provides thebody()
andbodyStream()
for more advanced use cases.That API has been significantly update since this issue was closed. What about the current API doesn’t work?