isohttpd 0.4.0

Dart native
Flutter Android iOS

A lightweight http server that runs in an isolate. Router and logs are included.

Isohttpd #

pub package

A lightweight http server that runs in an isolate. Powered by Iso

Example #

   import 'dart:io';
   import 'dart:async';
   import 'package:isohttpd/isohttpd.dart';

   Future<HttpResponse> handler(HttpRequest request, IsoLogger log) async {
     return jsonResponse(request, {"response": "ok"});
   }

   void main() async {
     // set routes
     final defaultRoute = IsoRoute(path: "*", handler: handler);
     final routes = <IsoRoute>[defaultRoute];
     final router = IsoRouter(routes);

     // run
     final iso = IsoHttpdRunner(host: "localhost", router: router);
     await iso.run(verbose: true);

     // listen to logs
     iso.logs.listen((String data) => print("$data"));
  iso.requestLogs.listen((ServerRequestLog data) => print("=> $data"));
     // idle
     final waiter = Completer<Null>();
     await waiter.future;
   }

Commands #

Start the server:

   await iso.run(startServer: false);
   iso.start();

Stop the server:

   iso.stop();

Server status:

   iso.status();

Utils #

Send a json response from a handler:

   jsonResponse(request, {"response": "ok"});

Decode multipart/form-data:

   final body = await decodeMultipartRequest(request);
   final dynamic data = body.data;

List a directory's content:

   final data = await directoryListing(Directory(somePath));
0
likes
100
pub points
55%
popularity

A lightweight http server that runs in an isolate. Router and logs are included.

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

ansterj@gmail.com

License

MIT (LICENSE)

Dependencies

body_parser, emodebug, extra_pedantic, iso, meta, path, pedantic

More

Packages that depend on isohttpd