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

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

Issue 82373002: Fix filtering out .dart files in release mode. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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 7fd758f99433ce53f6094817d5e63fe47a9c06ca..f491aab1ab13291b9b78b0263cd5dd66179a891e 100644
--- a/sdk/lib/_internal/pub/lib/src/barback/server.dart
+++ b/sdk/lib/_internal/pub/lib/src/barback/server.dart
@@ -16,6 +16,9 @@ import '../barback.dart';
import '../log.dart' as log;
import '../utils.dart';
+/// Callback for determining if an asset with [id] should be served or not.
+typedef bool AllowAsset(AssetId id);
+
/// A server that serves assets transformed by barback.
class BarbackServer {
/// The underlying HTTP server.
@@ -34,6 +37,15 @@ class BarbackServer {
/// The server's address.
final InternetAddress address;
+ /// Optional callback to determine if an asset should be served.
+ ///
+ /// This can be set to allow outside code to filter out assets. Pub serve
+ /// uses this after plug-ins are loaded to avoid serving ".dart" files in
+ /// release mode.
+ ///
+ /// If this is `null`, all assets may be served.
+ AllowAsset allowAsset;
+
/// The results of requests handled by the server.
///
/// These can be used to provide visual feedback for the server's processing.
@@ -91,6 +103,12 @@ class BarbackServer {
return;
}
+ // See if the asset should be blocked.
+ if (allowAsset != null && !allowAsset(id)) {
+ _notFound(request, "Asset $id is not available in this configuration.");
+ return;
+ }
+
_logRequest(request, "Loading $id");
barback.getAssetById(id).then((asset) {
return validateStream(asset.read()).then((stream) {

Powered by Google App Engine
This is Rietveld 408576698