I'm doing a small server based on the code in
http://dart.academy/easy-custom-web-servers-with-dart-and-redstone/. In my server I want one (or more) html page to be generated dynamically. I've found out that one way to set the proper content-type on the response, is to use an Interceptor like this:
@app.Interceptor(r"^\/.+\.html$")
htmlContent() {
app.chain.next(() {
app.response = app.response.change(headers: {"content-type": "text/html"});
});
}
Are there simpler or better ways to do it?
Could I also use this Interceptor to set the charset="utf-8"?
The reg.ex I picked, one that matches any path "/foo.html", of course also matches paths for static pages like "/index.html", but that doesn't seem to be a problem.