caddy/caddyhttp/templates
Matt Holt 4b1b329edb templates: Execute template loaded by later middlewares (#1649)
* templates: Execute template loaded by later middlewares

This is the beginning of an attempt to make the staticfiles file server
the only middleware that hits the disk and loads content. This may have
unknown implications. But the goal is to reduce duplication without
sacrificing performance. (We now call ServeContent here.)

This change loses about 15% of the req/sec of the old way of doing it,
but this way is arguably more correct since the file server is good at
serving static files; duplicating that logic in every middleware that
needs to hit the disk is not practical.

* httpserver: Introduce ResponseRecorder as per Tw's suggestions

It implements io.ReaderFrom and has some allocation-reducing
optimizations baked into it

* templates: Increase execution speed by ~10-15% after perf regression

By using httpserver.ResponseBuffer, we can reduce allocations and still
get what we want. It's a little tricky but it works so far.
2017-08-24 07:13:53 -06:00
..
testdata template: add test for custom function 2017-04-18 22:49:20 +08:00
setup_test.go Refactor how caddy.Context is stored and used 2016-06-20 11:59:23 -06:00
setup.go mitm, templates, context: Pool buffers to reduce allocations 2017-04-21 19:54:25 -06:00
templates_test.go templates: Execute template loaded by later middlewares (#1649) 2017-08-24 07:13:53 -06:00
templates.go templates: Execute template loaded by later middlewares (#1649) 2017-08-24 07:13:53 -06:00