shelf_simple_session 0.1.3

  • README.md
  • Installing
  • Versions
  • 0

shelf_simple_session

A very simple cookie based session handler for dart Shelf middleware.

Here is an example of usage (see example/session_example.dart)

    // simple handler that increments a counter stored in the session
      shelf.Response pingHandler(shelf.Request request) {
      
        // session() function gets a reference to the session map
        var map = session(request);
        var c = map['counter'];
        int counter = ( c == null ? 0 : c) +1;
        //store counter in the session
        map['counter'] = counter;
    
        return new shelf.Response.ok("ping counter=$counter");
      }
    
    
      var handler = const shelf.Pipeline()
          .addMiddleware(shelf.logRequests())
          .addMiddleware(sessionMiddleware(new SimpleSessionStore()))
          .addHandler(pingHandler);
    
      // listen on port 7001
      io.serve(handler, InternetAddress.ANY_IP_V4, 7001);

TO DO

This is super simple, and there are lots of enhancements that should be made:

  • The session maintenance / timeout code is not efficient
  • This wont work in a multi-isolate environment (needs some of way of sharing session data between isolates)
  • When Shelf gets proper cookie handling, the cookie code in here should be replaced
  • Tests. Could use some
  • Implement session data encryption

Use this package as a library

1. Depend on it

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


dependencies:
  shelf_simple_session: ^0.1.3

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_simple_session/shelf_simple_session.dart';
  
Version Uploaded Documentation Archive
0.1.3 Dec 8, 2016 Go to the documentation of shelf_simple_session 0.1.3 Download shelf_simple_session 0.1.3 archive
0.1.2 Oct 10, 2014 Go to the documentation of shelf_simple_session 0.1.2 Download shelf_simple_session 0.1.2 archive
0.1.1 Oct 9, 2014 Go to the documentation of shelf_simple_session 0.1.1 Download shelf_simple_session 0.1.1 archive
0.1.0 Oct 9, 2014 Go to the documentation of shelf_simple_session 0.1.0 Download shelf_simple_session 0.1.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
0
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0
Overall:
Weighted score of the above. [more]
0
Learn more about scoring.

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.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://www.dartlang.org/dart-2#migration.

Dependencies

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