Blog Logo
TAGS

Generating the Response Writing Expression for RequestDelegate Behind the Scenes of Minimal APIs

In this post, well start looking at how RequestDelegateFactory.Create() creates the final RequestDelegate, focusing on the different expressions that are generated depending on your handlers signature. The method takes the handler endpoint, uses the argument Expressions created by CreateArguments() and generates the Expression that writes the response. Were only going to look at the response writing part of the method in this post, so Ive glossed over some of the other aspects of the method. The important points shown include building argument binding expressions, creating the MethodCall Expression, generating the 400 Bad Request in case of a failure, and reading from the request body as shown in the previous post.