Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(435)

Unified Diff: tests/standalone/src/io/HttpServerHandlerTest.dart

Issue 10226002: Remove the RequestHandler interface from the HTTP library (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« runtime/bin/http_impl.dart ('K') | « runtime/bin/http_impl.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/src/io/HttpServerHandlerTest.dart
diff --git a/tests/standalone/src/io/HttpServerHandlerTest.dart b/tests/standalone/src/io/HttpServerHandlerTest.dart
index 20cb948dc66fab210576c2fe70cbf1bddc703811..52aed5c3eea7cc4472a4ced2b5109549ccc8dab5 100644
--- a/tests/standalone/src/io/HttpServerHandlerTest.dart
+++ b/tests/standalone/src/io/HttpServerHandlerTest.dart
@@ -6,21 +6,21 @@
#import("dart:io");
#import("dart:isolate");
-class Handler1 implements RequestHandler {
+class Handler1 {
void onRequest(HttpRequest request, HttpResponse response) {
response.outputStream.writeString("Handler 1");
response.outputStream.close();
}
}
-class Handler2 implements RequestHandler {
+class Handler2 {
void onRequest(HttpRequest request, HttpResponse response) {
response.outputStream.writeString("Handler 2");
response.outputStream.close();
}
}
-class French404Handler implements RequestHandler {
+class French404Handler {
void onRequest(HttpRequest request, HttpResponse response) {
response.statusCode = HttpStatus.NOT_FOUND;
response.reasonPhrase = "Non Trouvé";
@@ -39,11 +39,19 @@ class Server {
}
void addHandler(Function matcher, handler) {
- server.addRequestHandler(matcher, handler);
+ if (handler is Function) {
+ server.addRequestHandler(matcher, handler);
+ } else {
+ server.addRequestHandler(matcher, handler.onRequest);
+ }
}
void set defaultHandler(handler) {
- server.defaultRequestHandler = handler;
+ if (handler is Function) {
+ server.defaultRequestHandler = handler;
+ } else {
+ server.defaultRequestHandler = handler.onRequest;
+ }
}
void close() {
« runtime/bin/http_impl.dart ('K') | « runtime/bin/http_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698