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

Unified Diff: sdk/lib/_internal/pub/lib/src/barback/server.dart

Issue 167103003: Support serving from multiple directories using "pub serve". (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 10 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
Index: sdk/lib/_internal/pub/lib/src/barback/server.dart
diff --git a/sdk/lib/_internal/pub/lib/src/barback/server.dart b/sdk/lib/_internal/pub/lib/src/barback/server.dart
index 58864ca3fb7c3cde2aada90ed028e81d16fae284..f5fe5a10155b93c36129b4fe1eb447915b04241c 100644
--- a/sdk/lib/_internal/pub/lib/src/barback/server.dart
+++ b/sdk/lib/_internal/pub/lib/src/barback/server.dart
@@ -25,10 +25,14 @@ class BarbackServer {
/// The underlying HTTP server.
final HttpServer _server;
- /// The name of the root package, from whose `web` directory root assets will
- /// be served.
+ /// The name of the root package, from whose [rootDirectory] assets will be
+ /// served.
final String _rootPackage;
+ /// The directory in [_rootPackage] which will serve as the root of this
+ /// server.
+ final String rootDirectory;
+
/// The barback instance from which this serves assets.
final Barback barback;
@@ -61,12 +65,14 @@ class BarbackServer {
/// This server will serve assets from [barback], and use [rootPackage] as
/// the root package.
static Future<BarbackServer> bind(String host, int port,
- Barback barback, String rootPackage) {
- return Chain.track(HttpServer.bind(host, port))
- .then((server) => new BarbackServer._(server, barback, rootPackage));
+ Barback barback, String rootPackage, String rootDirectory) {
+ return Chain.track(HttpServer.bind(host, port)).then((server) {
+ return new BarbackServer._(server, barback, rootPackage, rootDirectory);
+ });
}
- BarbackServer._(HttpServer server, this.barback, this._rootPackage)
+ BarbackServer._(HttpServer server, this.barback, this._rootPackage,
+ this.rootDirectory)
: _server = server,
port = server.port,
address = server.address {
@@ -262,13 +268,13 @@ class BarbackServer {
var id = specialUrlToId(url);
if (id != null) return id;
- // Otherwise, it's a path in current package's web directory.
+ // Otherwise, it's a path in current package's [rootDirectory].
var parts = path.url.split(url.path);
// Strip the leading "/" from the URL.
if (parts.isNotEmpty && parts.first == "/") parts = parts.skip(1);
- var relativePath = path.url.join("web", path.url.joinAll(parts));
+ var relativePath = path.url.join(rootDirectory, path.url.joinAll(parts));
return new AssetId(_rootPackage, relativePath);
}
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/barback/load_transformers.dart ('k') | sdk/lib/_internal/pub/lib/src/command.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698