| 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) {
|
|
|