summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/subroute.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/caddyhttp/subroute.go')
-rw-r--r--modules/caddyhttp/subroute.go15
1 files changed, 7 insertions, 8 deletions
diff --git a/modules/caddyhttp/subroute.go b/modules/caddyhttp/subroute.go
index 13453a5..a324873 100644
--- a/modules/caddyhttp/subroute.go
+++ b/modules/caddyhttp/subroute.go
@@ -27,13 +27,12 @@ func init() {
// Subroute implements a handler that compiles and executes routes.
// This is useful for a batch of routes that all inherit the same
-// matchers, or for routes with matchers that must be have deferred
-// evaluation (e.g. if they depend on placeholders created by other
-// matchers that need to be evaluated first).
+// matchers, or for multiple routes that should be treated as a
+// single route.
//
-// You can also use subroutes to handle errors from specific handlers.
-// First the primary Routes will be executed, and if they return an
-// error, the Errors routes will be executed; in that case, an error
+// You can also use subroutes to handle errors from its handlers.
+// First the primary routes will be executed, and if they return an
+// error, the errors routes will be executed; in that case, an error
// is only returned to the entry point at the server if there is an
// additional error returned from the errors routes.
type Subroute struct {
@@ -71,11 +70,11 @@ func (sr *Subroute) Provision(ctx caddy.Context) error {
}
func (sr *Subroute) ServeHTTP(w http.ResponseWriter, r *http.Request, _ Handler) error {
- subroute := sr.Routes.BuildCompositeRoute(r)
+ subroute := sr.Routes.Compile()
err := subroute.ServeHTTP(w, r)
if err != nil && sr.Errors != nil {
r = sr.Errors.WithError(r, err)
- errRoute := sr.Errors.Routes.BuildCompositeRoute(r)
+ errRoute := sr.Errors.Routes.Compile()
return errRoute.ServeHTTP(w, r)
}
return err