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

Interop-compatible wrapper over the standard dart:io HTTP 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 {
  final host = 'localhost';
  final server = await HttpServer.bind(host, 8080);
  server.listen(listener(HelloHandler()));

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

class HelloHandler implements HttpHandler {
  @override
  Future<HttpResponse> handle(HttpRequest request) async =>
      HttpResponse(200, 'Hello! ${DateTime.now()}');
}
0
likes
0
pub points
47%
popularity

Publisher

verified publisherkarapetov.com

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

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

http_interop

More

Packages that depend on http_interop_io