shelf_docker_shutdown 1.0.0 copy "shelf_docker_shutdown: ^1.0.0" to clipboard
shelf_docker_shutdown: ^1.0.0 copied to clipboard

Close the HttpServer on process TERM signals.

example/shelf_docker_shutdown_example.dart

import 'package:shelf/shelf.dart';
import 'package:shelf/shelf_io.dart' as shelf_io;
import 'package:shelf_docker_shutdown/shelf_docker_shutdown.dart';

void main() async {
  var handler =
      const Pipeline().addMiddleware(logRequests()).addHandler(_echoRequest);

  var server = await shelf_io.serve(handler, 'localhost', 8080);

  // Enable content compression
  server.autoCompress = true;

  print('Serving at http://${server.address.host}:${server.port}');

  await server.closeOnTermSignal();
  print('Server shutdown ok.');
}

Response _echoRequest(Request request) =>
    Response.ok('Request for "${request.url}"');
2
likes
150
pub points
48%
popularity

Publisher

verified publisherkkazuo.com

Close the HttpServer on process TERM signals.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (license)

More

Packages that depend on shelf_docker_shutdown