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

Unified Diff: lib/src/server/server.dart

Issue 1644673002: Handle local files better in server mode (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Rebase Created 4 years, 11 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
« no previous file with comments | « no previous file | test/codegen/expect/collection/src/unmodifiable_wrappers.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/server/server.dart
diff --git a/lib/src/server/server.dart b/lib/src/server/server.dart
index 555bcedf1ca60a23e51e3f0324e50589c6738530..b5468dc39be08d784a644fc79901ecba70579007 100644
--- a/lib/src/server/server.dart
+++ b/lib/src/server/server.dart
@@ -254,17 +254,20 @@ class DevServer {
var out = new Directory(outDir);
if (!await out.exists()) await out.create(recursive: true);
- var mainHandler =
+ var generatedHandler =
shelf_static.createStaticHandler(outDir, defaultDocument: _entryPath);
var sourceHandler = shelf_static.createStaticHandler(compiler.inputBaseDir,
serveFilesOutsidePath: true);
+ // TODO(vsm): Is there a better builtin way to compose these handlers?
var topLevelHandler = (shelf.Request request) {
var path = request.url.path;
- if (path.endsWith('.dart')) {
- return sourceHandler(request);
- } else {
- return mainHandler(request);
+ // Prefer generated code
+ var response = generatedHandler(request);
+ if (response.statusCode == 404) {
+ // Fall back on original sources
+ response = sourceHandler(request);
}
+ return response;
};
var handler = const shelf.Pipeline()
« no previous file with comments | « no previous file | test/codegen/expect/collection/src/unmodifiable_wrappers.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698