http_interop_io 0.8.0 copy "http_interop_io: ^0.8.0" to clipboard
http_interop_io: ^0.8.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 {
  final host = 'localhost';
  final port = 8080;
  final server = await HttpServer.bind(host, port);
  server.listen(listener(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
160
points
46
downloads

Publisher

verified publisherkarapetov.com

Weekly Downloads

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