From 4a3a418156e25aae17659142a4bf9259d7702c44 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Tue, 9 Jul 2019 12:58:39 -0600 Subject: Flatten HTTP handler config (#2662) Differentiating middleware and responders has one benefit, namely that it's clear which module provides the response, but even then it's not a great advantage. Linear handler config makes a little more sense, giving greater flexibility and simplifying the core a bit, even though it's slightly awkward that handlers which are responders may not use the 'next' handler that is passed in at all. --- modules/caddyhttp/templates/templates.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/caddyhttp/templates') diff --git a/modules/caddyhttp/templates/templates.go b/modules/caddyhttp/templates/templates.go index e5bfa35..85b0bc2 100644 --- a/modules/caddyhttp/templates/templates.go +++ b/modules/caddyhttp/templates/templates.go @@ -28,7 +28,7 @@ import ( func init() { caddy.RegisterModule(caddy.Module{ - Name: "http.middleware.templates", + Name: "http.handlers.templates", New: func() interface{} { return new(Templates) }, }) } -- cgit v1.2.3 From eb8625f7744ba5e72b51549adc086e45313267cb Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Thu, 11 Jul 2019 17:02:57 -0600 Subject: Add error & subroute handlers; weakString; other minor handler changes --- modules/caddyhttp/templates/templates.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'modules/caddyhttp/templates') diff --git a/modules/caddyhttp/templates/templates.go b/modules/caddyhttp/templates/templates.go index 85b0bc2..9a41b6d 100644 --- a/modules/caddyhttp/templates/templates.go +++ b/modules/caddyhttp/templates/templates.go @@ -35,9 +35,9 @@ func init() { // Templates is a middleware which execute response bodies as templates. type Templates struct { - FileRoot string `json:"file_root,omitempty"` - MIMETypes []string `json:"mime_types,omitempty"` - Delimiters []string `json:"delimiters,omitempty"` + IncludeRoot string `json:"include_root,omitempty"` + MIMETypes []string `json:"mime_types,omitempty"` + Delimiters []string `json:"delimiters,omitempty"` } // Provision provisions t. @@ -107,8 +107,8 @@ func (t *Templates) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddy // executeTemplate executes the template contained in wb.buf and replaces it with the results. func (t *Templates) executeTemplate(rr caddyhttp.ResponseRecorder, r *http.Request) error { var fs http.FileSystem - if t.FileRoot != "" { - fs = http.Dir(t.FileRoot) + if t.IncludeRoot != "" { + fs = http.Dir(t.IncludeRoot) } ctx := &templateContext{ -- cgit v1.2.3