Skip to main content

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

Interop-compatible adapters for the standard dart:io HTTP client and server.

example/example.dart

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);

  print('Listening on http://$host:$port. Press Ctrl+C to stop.');
  final signal = await ProcessSignal.sigint.watch().first;
  stderr.writeln('$signal received, exiting');
  await server.close(force: true);
}

Future<Response> sayHello(Request request) async =>
    Response(200, Body.text('Hello! You requested ${request.uri}'), Headers());
1
likes
160
points
604
downloads

Documentation

API reference

Publisher

verified publisherkarapetov.com

Weekly Downloads

Interop-compatible adapters for the standard dart:io HTTP client and server.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

http_interop

More

Packages that depend on http_interop_io