jaysylvester / citizen

Node.js MVC web application framework. Includes routing, serving, caching, session management, and other helpful tools.
MIT License
100 stars 7 forks source link

Specifying a layout controller in the controller config results in a 500 loop #113

Closed jaysylvester closed 2 years ago

jaysylvester commented 3 years ago

fireController() doesn't check for the existence of the controller it's asked to fire, because that happens further up the chain in the initial request, so if the called controller config specifies a non-existent layout controller, the controller handoff causes fireController() to throw a 500 and get caught in a loop.

jaysylvester commented 2 years ago

handoff() now checks for the existence of the handoff controller (which includes layout controllers) and throws an error if it doesn't exist.

As part of this change, I also abstracted the controller config into its own method so it can be used in multiple locations. Controller config is now inherited by subsequent controllers in the chain, but include controllers are sandboxed; the config is reset prior to passing params to the include.