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

Unified Diff: pkg/gcloud/examples/x.dart

Issue 804973002: Add appengine/gcloud/mustache dependencies. (Closed) Base URL: git@github.com:dart-lang/pub-dartlang-dart.git@master
Patch Set: Added AUTHORS/LICENSE/PATENTS files Created 6 years 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 | « pkg/gcloud/examples/key.json ('k') | pkg/gcloud/lib/common.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/gcloud/examples/x.dart
diff --git a/pkg/gcloud/examples/x.dart b/pkg/gcloud/examples/x.dart
new file mode 100644
index 0000000000000000000000000000000000000000..59151588d5e17eebd0808fd4c895848e8b241fa3
--- /dev/null
+++ b/pkg/gcloud/examples/x.dart
@@ -0,0 +1,32 @@
+import 'dart:async';
+
+import 'package:googleapis_auth/auth_io.dart' as auth;
+import 'package:gcloud/storage.dart';
+import 'package:gcloud/http.dart';
+import 'package:gcloud/service_scope.dart' as ss;
+
+Future runApp() {
+ // The `runApp` function runs inside a context and can therefore
+ // access any registered values. In this case we use the `storage`
+ // object. But the `authenticatedClient` object is available as well.
+ return storageService.listBucketNames().listen(print).asFuture();
+}
+
+main() {
+ // Assumes we are running on a ComputeEngine VM with the storage scopes
+ // enabled.
+ auth.clientViaMetadataServer().then((httpClient) {
+ // Creates a new context and runs the given closure inside it.
+ ss.fork(() {
+ ss.registerScopeExitCallback(httpClient.close);
+
+ // We register the HTTP client.
+ registerAuthClientService(httpClient);
+
+ // We register the storage object inside the newly created service scope.
+ // This makes it available to all code running inside this context.
+ registerStorageService(new Storage(httpClient, 'my-project-id'));
+ return runApp();
+ });
+ });
+}
« no previous file with comments | « pkg/gcloud/examples/key.json ('k') | pkg/gcloud/lib/common.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698