Viewing version 0.5.0. Open the latest package page.
shelf
0.5.0Web Server Middleware for Dart
Readme
Web Server Middleware for Dart
Introduction
Shelf makes it easy to create and compose web servers and parts of web servers. How?
- Expose a small set of simple types.
- Map server logic into a simple function: a single argument for the request, the response is the return value.
- Trivially mix and match synchronous and asynchronous processing.
- Flexibliity to return a simple string or a byte stream with the same model.
Example
See example/example_server.dart
import 'package:shelf/shelf.dart' as shelf;
import 'package:shelf/shelf_io.dart' as io;
void main() {
var handler = const shelf.Pipeline().addMiddleware(shelf.logRequests())
.addHandler(_echoRequest);
io.serve(handler, 'localhost', 8080).then((server) {
print('Serving at http://${server.address.host}:${server.port}');
});
}
shelf.Response _echoRequest(shelf.Request request) {
return new shelf.Response.ok('Request for "${request.url}"');
}
Inspiration
- Connect for NodeJS.
- Read this great write-up to understand the overall philosophy of all of these models.
- Rack for Ruby.
- WSGI for Python.
Changelog
0.5.0
- Renamed
StacktoPipeline.
0.4.0
-
Access to headers for
RequestandResponseis now case-insensitive. -
The constructor for
Requesthas been simplified. -
Requestnow exposesurlwhich replacespathInfo,queryString, andpathSegments.
0.3.0+9
-
Removed old testing infrastructure.
-
Updated documentation address.
0.3.0+8
- Added a dependency on the
http_parserpackage.
0.3.0+7
- Removed unused dependency on the
mimepackage.
0.3.0+6
- Added a dependency on the
string_scannerpackage.
0.3.0+5
- Updated
pubspecdetails for move to Dart SDK.
0.3.0 2014-03-25
Response- NEW!
int get contentLength - NEW!
DateTime get expires - NEW!
DateTime get lastModified
- NEW!
Request- BREAKING
contentLengthis now read fromheaders. The constructor argument has been removed. - NEW! supports an optional
Stream<List<int>> bodyconstructor argument. - NEW!
Stream<List<int>> read()andFuture<String> readAsString([Encoding encoding]) - NEW!
DateTime get ifModifiedSince - NEW!
String get mimeType - NEW!
Encoding get encoding
- BREAKING
0.2.0 2014-03-06
- BREAKING Removed
Shelfprefix from all classes. - BREAKING
Responsehas drastically different constructors. - NEW!
Responsenow accepts a body of eitherStringorStream<List<int>>. - NEW!
Responsenow exposesencodingandmimeType.
0.1.0 2014-03-02
- First reviewed release
Installing
export PUB_HOSTED_URL=https://pub.mirror.p-hatan.ir
flutter pub add 'shelf:0.5.0'pubspec.yaml
name: shelf
version: 0.5.0
author: Dart Team <misc@dartlang.org>
description: Web Server Middleware for Dart
homepage: http://www.dartlang.org
environment:
sdk: '>=1.2.0 <2.0.0'
documentation: https://api.dartlang.org/apidocs/channels/be/dartdoc-viewer/shelf
dependencies:
collection: '>=0.9.1 <0.10.0'
http_parser: '>=0.0.0 <0.1.0'
path: '>=1.0.0 <2.0.0'
stack_trace: '>=0.9.2 <0.10.0'
dev_dependencies:
http: '>=0.9.2 <0.11.0'
scheduled_test: '>=0.10.0 <0.11.0'
unittest: '>=0.10.0 <0.11.0'
Version history
| Version | Published | Archive | SHA-256 |
|---|---|---|---|
| 0.0.0-dev | Cached · Upstream SHA-256 matched | Download | 4afe7167…1b7018 |
| 0.0.0-dev+1 | Cached · Upstream SHA-256 matched | Download | bf52b1ad…9134c7 |
| 0.0.1 | Cached · Upstream SHA-256 matched | Download | bff176f0…3215a2 |
| 0.1.0 | Cached · Upstream SHA-256 matched | Download | 568505d6…2af414 |
| 0.2.0 | Cached · Upstream SHA-256 matched | Download | 2acad0d2…a59f3a |
| 0.3.0 | Cached · Upstream SHA-256 matched | Download | a2ab589e…52ae28 |
| 0.3.0+1 | Cached · Upstream SHA-256 matched | Download | e90d8386…8a7ff6 |
| 0.3.0+2 | Cached · Upstream SHA-256 matched | Download | 3597889d…91ec5f |
| 0.3.0+3 | Cached · Upstream SHA-256 matched | Download | c0074eb5…085beb |
| 0.3.0+4 | Cached · Upstream SHA-256 matched | Download | ea625f24…0344bb |
| 0.3.0+6 | Cached · Upstream SHA-256 matched | Download | d25f50dc…6dbaec |
| 0.3.0+7 | Cached · Upstream SHA-256 matched | Download | ef72a780…0c0290 |
| 0.3.0+8 | Cached · Upstream SHA-256 matched | Download | 9c1e66ae…219e65 |
| 0.4.0 | Cached · Upstream SHA-256 matched | Download | 3b08fb62…df8108 |
| 0.5.0 | Cached · Upstream SHA-256 matched | Download | a3ee1d64…e49b8c |
| 0.5.0+1 | Cached · Upstream SHA-256 matched | Download | 278b4983…fee4b0 |
| 0.5.1 | Cached · Upstream SHA-256 matched | Download | d9f531b2…7e93f8 |
| 0.5.1+1 | Cached · Upstream SHA-256 matched | Download | 022aaed8…ccd73c |
| 0.5.2 | Cached · Upstream SHA-256 matched | Download | 74ce1e60…ab62d5 |
| 0.5.3 | Cached · Upstream SHA-256 matched | Download | 4b34cf05…c2e046 |
| 0.5.4 | Cached · Upstream SHA-256 matched | Download | 1d03f958…235fda |
| 0.5.4+1 | Cached · Upstream SHA-256 matched | Download | 9369e89d…42555e |
| 0.5.4+2 | Cached · Upstream SHA-256 matched | Download | 82366dae…7f3743 |
| 0.5.4+3 | Cached · Upstream SHA-256 matched | Download | 38e64be0…9924cf |
| 0.5.5 | Cached · Upstream SHA-256 matched | Download | e1813b8a…3988f1 |
| 0.5.5+1 | Cached · Upstream SHA-256 matched | Download | 2d75f5b2…516e72 |
| 0.5.6 | Cached · Upstream SHA-256 matched | Download | 2034faee…0d91df |
| 0.5.7 | Cached · Upstream SHA-256 matched | Download | ceb5c0cc…22f68e |
| 0.6.0 | Cached · Upstream SHA-256 matched | Download | 6f5c8021…faca7b |
| 0.6.1 | Cached · Upstream SHA-256 matched | Download | 84755ef6…a6a1d6 |
| 0.6.1+1 | Cached · Upstream SHA-256 matched | Download | 1f53eb9d…74c22d |
| 0.6.1+2 | Cached · Upstream SHA-256 matched | Download | 313d3c27…08116a |
| 0.6.1+3 | Cached · Upstream SHA-256 matched | Download | c00be6a3…22b311 |
| 0.6.2 | Cached · Upstream SHA-256 matched | Download | c7a20d3d…3ee237 |
| 0.6.2+1 | Cached · Upstream SHA-256 matched | Download | 8de62625…06ef8a |
| 0.6.3 | Cached · Upstream SHA-256 matched | Download | 93bf93b2…341d4a |
| 0.6.3+1 | Cached · Upstream SHA-256 matched | Download | 59b4d09c…5838ba |
| 0.6.4 | Cached · Upstream SHA-256 matched | Download | a1563783…364942 |
| 0.6.4+1 | Cached · Upstream SHA-256 matched | Download | c2fbffc4…6385b3 |
| 0.6.4+2 | Cached · Upstream SHA-256 matched | Download | 02945044…cbed43 |
| 0.6.4+3 | Cached · Upstream SHA-256 matched | Download | 3cb4475a…19c1af |
| 0.6.5 | Cached · Upstream SHA-256 matched | Download | 52177a1e…c7b28d |
| 0.6.5+1 | Cached · Upstream SHA-256 matched | Download | cb7ba373…ca4744 |
| 0.6.5+2 | Cached · Upstream SHA-256 matched | Download | 9d70d71e…b5b8ee |
| 0.6.5+3 | Cached · Upstream SHA-256 matched | Download | 70f564e7…5fd45e |
| 0.6.6 | Cached · Upstream SHA-256 matched | Download | 22e2aa03…954d92 |
| 0.6.7 | Cached · Upstream SHA-256 matched | Download | 3c1000c2…4237c9 |
| 0.6.7+1 | Cached · Upstream SHA-256 matched | Download | bff10984…175e95 |
| 0.6.7+2 | Cached · Upstream SHA-256 matched | Download | e5abb9e0…3b8f03 |
| 0.6.8 | Cached · Upstream SHA-256 matched | Download | 9818547d…ff1acb |
| 0.7.0 | Cached · Upstream SHA-256 matched | Download | 654dc74d…c7e98e |
| 0.7.1 | Cached · Upstream SHA-256 matched | Download | b6f70437…1a3808 |
| 0.7.2 | Cached · Upstream SHA-256 matched | Download | 18842d10…6511d1 |
| 0.7.3 | Cached · Upstream SHA-256 matched | Download | c0043920…a9bead |
| 0.7.3+1 | Cached · Upstream SHA-256 matched | Download | 32ddaace…bcc0c6 |
| 0.7.3+2 | Cached · Upstream SHA-256 matched | Download | 52ecabc1…ddfd5f |
| 0.7.3+3 | Cached · Upstream SHA-256 matched | Download | dd4a28b1…1d84e5 |
| 0.7.4 | Cached · Upstream SHA-256 matched | Download | 10b99738…99171e |
| 0.7.4+1 | Cached · Upstream SHA-256 matched | Download | e51ec952…531b28 |
| 0.7.5 | Cached · Upstream SHA-256 matched | Download | c256a075…2486ff |
| 0.7.6 | Cached · Upstream SHA-256 matched | Download | 86888c62…ea7b89 |
| 0.7.7 | Cached · Upstream SHA-256 matched | Download | 739463c8…c485cf |
| 0.7.8 | Cached · Upstream SHA-256 matched | Download | 257f7b85…30988a |
| 0.7.9 | Cached · Upstream SHA-256 matched | Download | d16d1197…80ee37 |
| 1.0.0-nullsafety.0 | Cached · Upstream SHA-256 matched | Download | e6536ccc…18f367 |
| 1.0.0 | Cached · Upstream SHA-256 matched | Download | c0710a5c…d361c6 |
| 1.1.0 | Cached · Upstream SHA-256 matched | Download | c2f658d2…258901 |
| 1.1.1 | Cached · Upstream SHA-256 matched | Download | cb24b18e…fafe55 |
| 1.1.2 | Cached · Upstream SHA-256 matched | Download | 83ad9c33…90f0d7 |
| 1.1.3 | Cached · Upstream SHA-256 matched | Download | 85a7ff40…8d0a1f |
| 1.1.4 | Cached · Upstream SHA-256 matched | Download | 26d22c68…8d6de5 |
| 1.2.0 | Cached · Upstream SHA-256 matched | Download | c240984c…18421d |
| 1.3.0 | Cached · Upstream SHA-256 matched | Download | 4592f6cb…ddc0c3 |
| 1.3.1 | Cached · Upstream SHA-256 matched | Download | f27c6406…1026d7 |
| 1.3.2 | Cached · Upstream SHA-256 matched | Download | 8ec60759…a30ea0 |
| 1.4.0 | Cached · Upstream SHA-256 matched | Download | c24a9613…73682c |
| 1.4.1 | Cached · Upstream SHA-256 matched | Download | ad29c505…180fa4 |
| 1.4.2 | Cached · Upstream SHA-256 matched | Download | e7dd780a…39ef12 |
| 1.4.3 | Cached · Upstream SHA-256 matched | Download | e75e9cf3…3d5a48 |
Dependencies
collection "\u003e=0.9.1 \u003c0.10.0"
http_parser "\u003e=0.0.0 \u003c0.1.0"
path "\u003e=1.0.0 \u003c2.0.0"
stack_trace "\u003e=0.9.2 \u003c0.10.0"