dart_side 0.0.1-dev copy "dart_side: ^0.0.1-dev" to clipboard
dart_side: ^0.0.1-dev copied to clipboard

outdated

A Simple and Pure Dart Http Server for Small Projects

Dart Side #

Simple and Pure Dart Http server

Usage #

A simple usage example:

import 'dart:io';

import 'package:dart_side/dart_side.dart';

Future<void> main() async {
  final HttpServer server = await HttpServer.bind(
    InternetAddress.loopbackIPv4,
    4040,
  );

  print('Listening on localhost:${server.port}');

  final DServer handler = new DServer();

  handler.handle(
    method: Method.GET,
    handler: Handler(
      path: '/v1/schedules',
      callback: () {
        // Somthing like Paginate list
        return <String, dynamic>{
          'items': <String>[
            'schedule 1',
            'schedule 2',
            'schedule 3',
            'schedule 4',
            'schedule 5',
          ],
        };
      },
    ),
  );

  handler.handle(
    method: Method.GET,
    handler: Handler(
      rPath: r'/v1/schedules/\d+',
      callback: () {
        return <String, dynamic>{
          'read': 'schedule',
          'id': -1,
        };
      },
    ),
  );

  await for (HttpRequest request in server) {
    await handler.serve(request);
  }
}

Features and bugs #

Please file feature requests and bugs at the issue tracker.

2
likes
0
pub points
0%
popularity

Publisher

verified publisherdizoft.ru

A Simple and Pure Dart Http Server for Small Projects

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on dart_side