extend/cowboy — pull request #630 by NineFX (2013-12-03 22:42:36+00:00)
Title: Validate the handlers are valid during route compilation

This patch to cowboy_router.erl adds two methods, is_handler_valid/1 and check_handler/1 . is_handler_valid/1 returns a boolean. check_handler/1 throws a badarg error if invalid. They attempt to load the handler as a module and verify that it exports init/3. The checks are integrated into the compile method. Unit tests are included. The test suites pass except for echo_body_max_length, but I'm sure I didn't break that. Dialyzer doesn't report errors.

I had to modify the existing compile unit tests to use valid handler modules so they would pass.

I think this will be useful for Farwest where users can edit routes in their web browser.