rewriteAs function
Creates a Middleware
that returns a html
response with responseBody
if the requestedUri
doesn't have a MIME type.
If this heuristic doesn't work well for you, please file an issue. Furthermore, PRs are welcome.
This needs some understanding of package: shelf
.
Implementation
Middleware rewriteAs(String responseBody) =>
createMiddleware(requestHandler: (req) {
return _shouldBeRewritten(req.requestedUri)
? new Response.ok(responseBody, headers: {_contentType: _textHtml})
: null;
});