Like Express, body-parser is a function to parse the body of an incoming request.
By default, Teasim will parse the body with content-type of:
text/plain
application/json
multipart/form-data
application/x-www-form-urlencoded
And assign the value to Context.body
.
Then you can get body from body
as:
If you want to support more content-type
s, you can use the onParse
method:
The returned value will be assigned to Context.body. If not, Teasim will continue iterating through additional parser functions assigned by onParse
until either body is assigned or all parsers have been executed.
You can also use request
to add custom parsing behavior.
For example, parsing GraphQL on a specific path: