diff options
Diffstat (limited to 'slips/src/app/Marina/Web/Handlers/Dispatcher.cs')
| -rw-r--r-- | slips/src/app/Marina/Web/Handlers/Dispatcher.cs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/slips/src/app/Marina/Web/Handlers/Dispatcher.cs b/slips/src/app/Marina/Web/Handlers/Dispatcher.cs new file mode 100644 index 0000000..af1bd84 --- /dev/null +++ b/slips/src/app/Marina/Web/Handlers/Dispatcher.cs @@ -0,0 +1,24 @@ +using Marina.Infrastructure;
+using Marina.Web.Commands;
+using Marina.Web.Http;
+
+namespace Marina.Web.Handlers {
+ public class Dispatcher {
+ private readonly IRegisteredHandlers handlers;
+
+ public Dispatcher() : this( new RegisteredHandlers( ) ) {}
+
+ public Dispatcher( IRegisteredHandlers handlers ) {
+ this.handlers = handlers;
+ }
+
+ public ICommand FindFor( IHttpGateway request ) {
+ foreach ( IRequestHandler handler in handlers.All( ) ) {
+ if ( handler.IsSatisfiedBy( request ) ) {
+ return handler;
+ }
+ }
+ return new RedirectCommand( );
+ }
+ }
+}
\ No newline at end of file |
