1.1.1
This commit is contained in:
parent
525a818054
commit
0b518f36aa
6 changed files with 61 additions and 1 deletions
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/shelf.iml" filepath="$PROJECT_DIR$/.idea/shelf.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
18
.idea/shelf.iml
Normal file
18
.idea/shelf.iml
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="WEB_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/.pub" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/packages" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/test/packages" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="Dart SDK" level="project" />
|
||||||
|
<orderEntry type="library" name="Dart Packages" level="project" />
|
||||||
|
</component>
|
||||||
|
</module>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
26
example/dartlang_org.dart
Normal file
26
example/dartlang_org.dart
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
import 'dart:io';
|
||||||
|
import 'package:angel_framework/angel_framework.dart';
|
||||||
|
import 'package:angel_shelf/angel_shelf.dart';
|
||||||
|
import 'package:shelf_proxy/shelf_proxy.dart';
|
||||||
|
|
||||||
|
main() async {
|
||||||
|
var app = new Angel();
|
||||||
|
|
||||||
|
// `shelf` request handler
|
||||||
|
var shelfHandler = proxyHandler('https://www.dartlang.org');
|
||||||
|
|
||||||
|
// Use `embedShelf` to adapt a `shelf` handler for use within Angel.
|
||||||
|
var angelHandler = embedShelf(shelfHandler);
|
||||||
|
|
||||||
|
// A normal Angel route.
|
||||||
|
app.get('/angel', (req, ResponseContext res) {
|
||||||
|
res.write('Hooray for `package:angel_shelf`!');
|
||||||
|
res.end(); // End execution of handlers, so we don't proxy to dartlang.org when we don't need to.
|
||||||
|
});
|
||||||
|
|
||||||
|
// Proxy any other request through to dartlang.org
|
||||||
|
app.after.add(angelHandler);
|
||||||
|
|
||||||
|
var server = await app.startServer(InternetAddress.LOOPBACK_IP_V4, 8080);
|
||||||
|
print('Proxying at http://${server.address.host}:${server.port}');
|
||||||
|
}
|
|
@ -60,6 +60,7 @@ Future mergeShelfResponse(
|
||||||
angelResponse.headers.addAll(shelfResponse.headers);
|
angelResponse.headers.addAll(shelfResponse.headers);
|
||||||
angelResponse.statusCode = shelfResponse.statusCode;
|
angelResponse.statusCode = shelfResponse.statusCode;
|
||||||
angelResponse.properties['shelf_context'] = shelfResponse.context;
|
angelResponse.properties['shelf_context'] = shelfResponse.context;
|
||||||
|
angelResponse.properties['shelf_response'] = shelfResponse;
|
||||||
await shelfResponse.read().forEach(angelResponse.buffer.add);
|
await shelfResponse.read().forEach(angelResponse.buffer.add);
|
||||||
angelResponse.end();
|
angelResponse.end();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name: angel_shelf
|
name: angel_shelf
|
||||||
description: Shelf interop with Angel.
|
description: Shelf interop with Angel.
|
||||||
version: 1.1.0
|
version: 1.1.1
|
||||||
author: Tobe O <thosakwe@gmail.com>
|
author: Tobe O <thosakwe@gmail.com>
|
||||||
homepage: https://github.com/angel-dart/shelf
|
homepage: https://github.com/angel-dart/shelf
|
||||||
environment:
|
environment:
|
||||||
|
@ -11,4 +11,5 @@ dependencies:
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
angel_diagnostics: ^1.0.0
|
angel_diagnostics: ^1.0.0
|
||||||
angel_test: ^1.0.0
|
angel_test: ^1.0.0
|
||||||
|
shelf_proxy: ^0.1.0
|
||||||
test: ^0.12.0
|
test: ^0.12.0
|
Loading…
Reference in a new issue