Skip to content

Instantly share code, notes, and snippets.

@wullemsb
Created April 9, 2019 06:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wullemsb/4fe7cd8fe952527335ce34a83b839a6d to your computer and use it in GitHub Desktop.
Save wullemsb/4fe7cd8fe952527335ce34a83b839a6d to your computer and use it in GitHub Desktop.
public class SchemaMiddleware
{
private readonly RequestDelegate _next;
public SchemaMiddleware(RequestDelegate next)
{
_next = next;
}
public async Task Invoke(HttpContext context, OrdersSchema schema)
{
using (var printer = new SchemaPrinter(schema))
{
context.Response.ContentType = "application/text";
context.Response.StatusCode = (int)HttpStatusCode.OK;
await context.Response.WriteAsync(printer.Print());
return;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment