shelf_plus 1.10.0 copy "shelf_plus: ^1.10.0" to clipboard
shelf_plus: ^1.10.0 copied to clipboard

Shelf Plus is a quality of life addon for your server-side development within the Shelf platform.

example/example.dart

import 'dart:io';

import 'package:shelf_plus/shelf_plus.dart';

void main() => shelfRun(init);

Handler init() {
  var app = Router().plus;

  app.get('/text', () => 'a text');

  app.get('/binary', () => File('data.zip').openRead());

  app.get('/json', () => {'name': 'John', 'age': 42});

  app.get('/class', () => Person('Theo'));

  app.get('/handler', () => typeByExtension('html') >> '<h1>Hello</h1>');

  app.get('/file', () => File('thesis.pdf'));

  return app.call;
}

class Person {
  final String name;

  Person(this.name);

  // can be generated by tools (i.e. json_serializable package)
  Map<String, dynamic> toJson() => {'name': name};
}
97
likes
160
points
3.91k
downloads

Publisher

verified publisherfelix-blaschke.de

Weekly Downloads

Shelf Plus is a quality of life addon for your server-side development within the Shelf platform.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

mime_type, shelf, shelf_hotreload, shelf_router, shelf_static, shelf_web_socket, web_socket_channel

More

Packages that depend on shelf_plus