shelf 0.5.0+1

  • Installing
  • Versions
  • 48

Web Server Middleware for Dart


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.


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

  io.serve(handler, 'localhost', 8080).then((server) {
    print('Serving at http://${}:${server.port}');

shelf.Response _echoRequest(shelf.Request request) {
  return new shelf.Response.ok('Request for "${request.url}"');



  • Allow scheduled_test development dependency up to v0.12.0


  • Renamed Stack to Pipeline.


  • Access to headers for Request and Response is now case-insensitive.

  • The constructor for Request has been simplified.

  • Request now exposes url which replaces pathInfo, queryString, and pathSegments.


  • Removed old testing infrastructure.

  • Updated documentation address.


  • Added a dependency on the http_parser package.


  • Removed unused dependency on the mime package.


  • Added a dependency on the string_scanner package.


  • Updated pubspec details for move to Dart SDK.

0.3.0 2014-03-25

  • Response
    • NEW! int get contentLength
    • NEW! DateTime get expires
    • NEW! DateTime get lastModified
  • Request
    • BREAKING contentLength is now read from headers. The constructor argument has been removed.
    • NEW! supports an optional Stream<List<int>> body constructor argument.
    • NEW! Stream<List<int>> read() and Future<String> readAsString([Encoding encoding])
    • NEW! DateTime get ifModifiedSince
    • NEW! String get mimeType
    • NEW! Encoding get encoding

0.2.0 2014-03-06

  • BREAKING Removed Shelf prefix from all classes.
  • BREAKING Response has drastically different constructors.
  • NEW! Response now accepts a body of either String or Stream<List<int>>.
  • NEW! Response now exposes encoding and mimeType.

0.1.0 2014-03-02

  • First reviewed release

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  shelf: ^0.5.0+1

2. Install it

You can install packages from the command line:

with pub:

$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:shelf/shelf.dart';
Version Uploaded Documentation Archive
0.7.4 Dec 17, 2018 Go to the documentation of shelf 0.7.4 Download shelf 0.7.4 archive
0.7.3+3 Jul 16, 2018 Go to the documentation of shelf 0.7.3+3 Download shelf 0.7.3+3 archive
0.7.3+2 Jul 10, 2018 Go to the documentation of shelf 0.7.3+2 Download shelf 0.7.3+2 archive
0.7.3+1 May 22, 2018 Go to the documentation of shelf 0.7.3+1 Download shelf 0.7.3+1 archive
0.7.3 May 2, 2018 Go to the documentation of shelf 0.7.3 Download shelf 0.7.3 archive
0.7.2 Jan 4, 2018 Go to the documentation of shelf 0.7.2 Download shelf 0.7.2 archive
0.7.1 Oct 26, 2017 Go to the documentation of shelf 0.7.1 Download shelf 0.7.1 archive
0.7.0 Aug 29, 2017 Go to the documentation of shelf 0.7.0 Download shelf 0.7.0 archive
0.6.8 Jun 23, 2017 Go to the documentation of shelf 0.6.8 Download shelf 0.6.8 archive
0.6.7+2 Dec 6, 2016 Go to the documentation of shelf 0.6.7+2 Download shelf 0.6.7+2 archive

All 58 versions...

Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

This package version is not analyzed, because it is more than two years old. Check the latest stable version for its analysis.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Maintenance issues and suggestions

Running dartdoc failed. (-10 points)

Make sure dartdoc runs without any issues.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.2.0 <2.0.0