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

Side by Side Diff: lib/src/barback/barback_server.dart

Issue 1295803003: Upgrade to shelf 0.6.0. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | lib/src/oauth2.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library pub.barback.server; 5 library pub.barback.server;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import 'package:barback/barback.dart'; 10 import 'package:barback/barback.dart';
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 error: "Asset $id is not available in this configuration.", 112 error: "Asset $id is not available in this configuration.",
113 asset: id); 113 asset: id);
114 } 114 }
115 115
116 return environment.barback.getAssetById(id).then((result) { 116 return environment.barback.getAssetById(id).then((result) {
117 return result; 117 return result;
118 }).then((asset) => _serveAsset(request, asset)).catchError((error, trace) { 118 }).then((asset) => _serveAsset(request, asset)).catchError((error, trace) {
119 if (error is! AssetNotFoundException) throw error; 119 if (error is! AssetNotFoundException) throw error;
120 return environment.barback.getAssetById(id.addExtension("/index.html")) 120 return environment.barback.getAssetById(id.addExtension("/index.html"))
121 .then((asset) { 121 .then((asset) {
122 if (request.url.path.endsWith('/')) return _serveAsset(request, asset); 122 if (request.url.path.isEmpty || request.url.path.endsWith('/')) {
123 return _serveAsset(request, asset);
124 }
123 125
124 // We only want to serve index.html if the URL explicitly ends in a 126 // We only want to serve index.html if the URL explicitly ends in a
125 // slash. For other URLs, we redirect to one with the slash added to 127 // slash. For other URLs, we redirect to one with the slash added to
126 // implicitly support that too. This follows Apache's behavior. 128 // implicitly support that too. This follows Apache's behavior.
127 logRequest(request, "302 Redirect to ${request.url}/"); 129 logRequest(request, "302 Redirect to /${request.url}/");
128 return new shelf.Response.found('${request.url}/'); 130 return new shelf.Response.found('/${request.url}/');
129 }).catchError((newError, newTrace) { 131 }).catchError((newError, newTrace) {
130 // If we find neither the original file or the index, we should report 132 // If we find neither the original file or the index, we should report
131 // the error about the original to the user. 133 // the error about the original to the user.
132 throw newError is AssetNotFoundException ? error : newError; 134 throw newError is AssetNotFoundException ? error : newError;
133 }); 135 });
134 }).catchError((error, trace) { 136 }).catchError((error, trace) {
135 if (error is! AssetNotFoundException) { 137 if (error is! AssetNotFoundException) {
136 trace = new Chain.forTrace(trace); 138 trace = new Chain.forTrace(trace);
137 logRequest(request, "$error\n$trace"); 139 logRequest(request, "$error\n$trace");
138 140
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 bool get isSuccess => error == null; 202 bool get isSuccess => error == null;
201 203
202 /// Whether the request was served unsuccessfully. 204 /// Whether the request was served unsuccessfully.
203 bool get isFailure => !isSuccess; 205 bool get isFailure => !isSuccess;
204 206
205 BarbackServerResult._success(this.url, this.id) 207 BarbackServerResult._success(this.url, this.id)
206 : error = null; 208 : error = null;
207 209
208 BarbackServerResult._failure(this.url, this.id, this.error); 210 BarbackServerResult._failure(this.url, this.id, this.error);
209 } 211 }
OLDNEW
« no previous file with comments | « no previous file | lib/src/oauth2.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698