http_interop_io 0.9.0 copy "http_interop_io: ^0.9.0" to clipboard
http_interop_io: ^0.9.0 copied to clipboard

Interop-compatible wrapper over the standard dart:io HTTP server.

example/example.dart

import 'dart:convert';
import 'dart:io';

import 'package:http_interop/http_interop.dart';
import 'package:http_interop_io/http_interop_io.dart';

Future<void> main() async {
  const host = 'localhost';
  const port = 8080;
  final server = await HttpServer.bind(host, port);
  server.listenInterop(sayHello);

  ProcessSignal.sigint.watch().listen((event) async {
    stderr.writeln('$event received, exiting');
    await server.close(force: true);
    exit(0);
  });
  print('Listening on http://$host:$port. Press Ctrl+C to stop.');
}

Future<Response> sayHello(Request request) async =>
    Response(200, Body.text('Hello! ${DateTime.now()}', utf8), Headers());
0
likes
150
pub points
42%
popularity

Publisher

verified publisherkarapetov.com

Interop-compatible wrapper over the standard dart:io HTTP server.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

http_interop

More

Packages that depend on http_interop_io