| 684 | route(route: RouteEntry): Binding; |
| 685 | |
| 686 | route<T extends object>( |
| 687 | routeOrVerb: RouteEntry | string, |
| 688 | path?: string, |
| 689 | spec?: OperationObject, |
| 690 | controllerCtorOrHandler?: ControllerClass<T> | Function, |
| 691 | controllerFactory?: ControllerFactory<T>, |
| 692 | methodName?: string, |
| 693 | ): Binding { |
| 694 | if (typeof routeOrVerb === 'object') { |
| 695 | const r = routeOrVerb; |
| 696 | // Encode the path to escape special chars |
| 697 | return this.bindRoute(r); |
| 698 | } |
| 699 | |
| 700 | if (!path) { |
| 701 | throw new AssertionError({ |
| 702 | message: 'path is required for a controller-based route', |
| 703 | }); |
| 704 | } |
| 705 | |
| 706 | if (!spec) { |
| 707 | throw new AssertionError({ |
| 708 | message: 'spec is required for a controller-based route', |
| 709 | }); |
| 710 | } |
| 711 | |
| 712 | if (arguments.length === 4) { |
| 713 | if (!controllerCtorOrHandler) { |
| 714 | throw new AssertionError({ |
| 715 | message: 'handler function is required for a handler-based route', |
| 716 | }); |
| 717 | } |
| 718 | return this.route( |
| 719 | new Route(routeOrVerb, path, spec, controllerCtorOrHandler as Function), |
| 720 | ); |
| 721 | } |
| 722 | |
| 723 | if (!controllerCtorOrHandler) { |
| 724 | throw new AssertionError({ |
| 725 | message: 'controller is required for a controller-based route', |
| 726 | }); |
| 727 | } |
| 728 | |
| 729 | if (!methodName) { |
| 730 | throw new AssertionError({ |
| 731 | message: 'methodName is required for a controller-based route', |
| 732 | }); |
| 733 | } |
| 734 | |
| 735 | return this.route( |
| 736 | new ControllerRoute( |
| 737 | routeOrVerb, |
| 738 | path, |
| 739 | spec, |
| 740 | controllerCtorOrHandler as ControllerClass<T>, |
| 741 | controllerFactory, |
| 742 | methodName, |
| 743 | ), |