Chromium Code Reviews| Index: runtime/bin/http_impl.dart |
| diff --git a/runtime/bin/http_impl.dart b/runtime/bin/http_impl.dart |
| index ae9243af27be45418a69f3e261deb8e04e488f22..619def0c8090003287b903ff925c21b85ecd0092 100644 |
| --- a/runtime/bin/http_impl.dart |
| +++ b/runtime/bin/http_impl.dart |
| @@ -794,16 +794,8 @@ class _HttpConnection extends _HttpConnectionBase { |
| class _RequestHandlerRegistration { |
| - _RequestHandlerRegistration(Function this._matcher, Object this._handler); |
| + _RequestHandlerRegistration(Function this._matcher, Function this._handler); |
| Function _matcher; |
| - RequestHandler _handler; |
| -} |
| - |
| - |
| -class _RequestHandlerImpl implements RequestHandler { |
| - _RequestHandlerImpl(Function this._handler); |
| - void onRequest(HttpRequest request, HttpResponse response) => |
| - _handler(request, response); |
| Function _handler; |
| } |
| @@ -838,14 +830,13 @@ class _HttpServer implements HttpServer { |
| _closeServer = false; |
| } |
| - addRequestHandler(bool matcher(String path), Object handler) { |
| - if (handler is Function) { |
| - handler = new _RequestHandlerImpl(handler); |
| - } |
| + addRequestHandler(bool matcher(String path), |
| + void handler(HttpRequest request, HttpResponse response)) { |
| _handlers.add(new _RequestHandlerRegistration(matcher, handler)); |
| } |
| - void set defaultRequestHandler(Object handler) { |
| + void set defaultRequestHandler( |
| + void handler(HttpRequest request, HttpResponse response)) { |
| _defaultHandler = handler; |
| } |
| @@ -874,9 +865,9 @@ class _HttpServer implements HttpServer { |
| void _handleRequest(HttpRequest request, HttpResponse response) { |
| for (int i = 0; i < _handlers.length; i++) { |
| if (_handlers[i]._matcher(request)) { |
| - var handler = _handlers[i]._handler; |
| + Function handler = _handlers[i]._handler; |
| try { |
| - handler.onRequest(request, response); |
| + handler(request, response); |
| } catch (var e) { |
|
Anders Johnsen
2012/04/25 08:46:23
We should consider doing something with the Stackt
Søren Gjesse
2012/04/25 08:54:41
Yes, that is a general issue with error callbacks
|
| if (_onError != null) { |
| _onError(e); |
| @@ -887,11 +878,7 @@ class _HttpServer implements HttpServer { |
| } |
| if (_defaultHandler != null) { |
|
Anders Johnsen
2012/04/25 08:46:23
!==, as you wrote, we support taking classes using
Søren Gjesse
2012/04/25 08:54:41
We only support functions now.
|
| - if (_defaultHandler is Function) { |
| - _defaultHandler(request, response); |
| - } else { |
| - _defaultHandler.onRequest(request, response); |
| - } |
| + _defaultHandler(request, response); |
| } else { |
| response.statusCode = HttpStatus.NOT_FOUND; |
| response.outputStream.close(); |