http_interop_io 0.7.0 copy "http_interop_io: ^0.7.0" to clipboard
http_interop_io: ^0.7.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(HelloHandler()));

  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.');
}

class HelloHandler implements Handler {
  @override
  Future<Response> handle(Request request) async =>
      Response(200, Body.text('Hello! ${DateTime.now()}', utf8), Headers());
}
0
likes
140
pub points
32%
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