|
- <%
- Class Dispatcher
- ' Given a Router.Match(...) result (or Nothing), resolves the controller
- ' key - falling back to "NotFound" when nothing matched, or when the
- ' matched key doesn't map to a known controller - then constructs, Inits,
- ' and Executes the corresponding controller. controllerKey and controller
- ' are ByRef outputs: Select Case controllerKey after calling this to pick
- ' the matching view (its filename must equal the resolved key).
- Public Sub Dispatch(ByRef app, ByRef routeMatch, ByRef controllerKey, ByRef controller)
- Dim routeParams
-
- If routeMatch Is Nothing Then
- controllerKey = "NotFound"
- Set routeParams = Nothing
- Else
- controllerKey = routeMatch.Item("ControllerName")
- Set routeParams = routeMatch.Item("Params")
- End If
-
- Select Case controllerKey
- Case "Home"
- Set controller = New HomeController
- Case "Greet"
- Set controller = New GreetController
- Case Else
- controllerKey = "NotFound"
- Set controller = New NotFoundController
- End Select
-
- controller.Init app, routeParams
- controller.Execute
- End Sub
- End Class
- %>
|