shelf_path 0.1.8

  • Installing
  • Versions
  • 49

Path Parameters for Dart Shelf

Pub Version


Provides a small library for Shelf to decouple producers of path parameters such as routers from consumers like your own handlers or other middleware like binding frameworks.

This supports interoperability so that you can plug and play which middleware you like as long as they support Dart Path.

In a nutshell, Shelf Path encapsulates the storage of path parameters in the Shelf Request context property. It exposes two sets of functions:

  1. Functions for consumers to Read path properties: getPathParameters, getPathParameter
  2. Functions for producers to Write path properties: setPathParameters, setPathParameter, addPathParameter


Say we have an end point that serves up queries on a nomintated bank account and supports filtering by a minimum amount. The requests look like

GET /banking/account/123456/deposit?minAmount=20

One way to represent this is using the powerful Uri Template standard which is supported by the very useful Dart uri package. It supports both segment parameters and query parameters.

For example


which has two path variables:

  1. accountId
  2. minAmount


Shelf Middleware such as routers can match the request path against this template and a map like

  'accountId': '123456',
  'minAmount': '20'

These path parameters can now be added to the context using the Shelf Path function addPathParameters

var pathParams = {
  'accountId': '123456',
  'minAmount': '20'



An end user can now write a handler and extract the path parameters using getPathParameter

depositSearchHandler(request) {
  var accountId = getPathParameter(request, 'accountId');
  var minAmount = getPathParameter(request, 'minAmount');

  return new Response.ok("Querying deposits for account $accountId for amounts >= $minAmount");

Compatible Middleware




  • removed dependency from uri package


  • increased upper bound on shelf


  • bug fix in addPathParametersToContext


  • deprecated some functions
  • upgraded minimum shelf version requirement
  • fixed bug due to immutable context


  • First release

Use this package as a library

1. Depend on it

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

  shelf_path: "^0.1.8"

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:

      import 'package:shelf_path/shelf_path.dart';
Version Uploaded Documentation Archive
0.1.8 Apr 10, 2016 Go to the documentation of shelf_path 0.1.8 Download shelf_path 0.1.8 archive
0.1.7 Aug 12, 2015 Go to the documentation of shelf_path 0.1.7 Download shelf_path 0.1.7 archive
0.1.6 Jun 25, 2015 Go to the documentation of shelf_path 0.1.6 Download shelf_path 0.1.6 archive
0.1.5 Jun 25, 2015 Go to the documentation of shelf_path 0.1.5 Download shelf_path 0.1.5 archive
0.1.4 Jun 25, 2015 Go to the documentation of shelf_path 0.1.4 Download shelf_path 0.1.4 archive
0.1.3 Jun 23, 2015 Go to the documentation of shelf_path 0.1.3 Download shelf_path 0.1.3 archive
0.1.2 Mar 20, 2015 Go to the documentation of shelf_path 0.1.2 Download shelf_path 0.1.2 archive
0.1.1+1 Aug 17, 2014 Go to the documentation of shelf_path 0.1.1+1 Download shelf_path 0.1.1+1 archive
0.1.1 Jul 19, 2014 Go to the documentation of shelf_path 0.1.1 Download shelf_path 0.1.1 archive
0.1.0 Jul 12, 2014 Go to the documentation of shelf_path 0.1.0 Download shelf_path 0.1.0 archive

All 11 versions...


We analyzed this package on Jul 13, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3


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


Detected platforms: Flutter, web, other

No platform restriction found in primary library package:shelf_path/shelf_path.dart.


  • Package is too old.

    The package was released more than two years ago.

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use shelf_path.dart.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 1 hint.

    Run dartfmt to format lib/shelf_path.dart.


Package Constraint Resolved Available
Direct dependencies
shelf >=0.5.4+2 <0.7.0 0.6.8 0.7.3+2
Transitive dependencies
async 1.13.3 2.0.7
charcode 1.1.2
collection 1.14.10
http_parser 3.1.2
path 1.6.1
source_span 1.4.0
stack_trace 1.9.2
stream_channel 1.6.7+1
string_scanner 1.0.2
typed_data 1.1.5
Dev dependencies
test ^0.12.0