shelf_cookie 1.0.2 copy "shelf_cookie: ^1.0.2" to clipboard
shelf_cookie: ^1.0.2 copied to clipboard

outdated

Cookie parser middleware for the Shelf ecosystem. Reads cookies in request, sets cookies in response.

example/example.dart

import 'package:shelf/shelf.dart' as shelf;
import 'package:shelf_cookie/shelf_cookie.dart';

void main() {
  /// Request contains cookie header.
  /// e.g. 'cookie': 'ping=foo'
  var _ = const shelf.Pipeline()
      .addMiddleware(cookieParser())
      .addHandler((req) async {
    CookieParser cookies = req.context['cookies'];
    if (cookies.get('ping') == 'foo') {
      cookies.set('pong', 'bar');
    }
    // Response will set cookie header.
    // e.g. 'set-cookie': 'ping=foo, pong=bar'
    return shelf.Response.ok('OK');
  });
}
6
likes
0
pub points
9%
popularity

Publisher

unverified uploader

Cookie parser middleware for the Shelf ecosystem. Reads cookies in request, sets cookies in response.

Repository (GitHub)
View/report issues

Documentation

Documentation

License

unknown (LICENSE)

Dependencies

shelf

More

Packages that depend on shelf_cookie