http_sugar 0.0.1

Flutter Android iOS

Sugar methods for HttpRequest and HttpResponse

http_sugar #

Sugar methods for HttpRequest and HttpResponse

GitHub stars Twitter Follow

Usage #

import 'dart:io';
import 'package:http_sugar/http_sugar.dart';

void main() async {
  final server = await HttpServer.bind(InternetAddress.anyIPv4, 3000);

  await for (HttpRequest req in server) {
    final body = await req.toJson();

    switch (body['result']) {
      case 'success':
        req.response.success();
        break;

      case 'error':
        req.response.error();
        break;

      case 'notFound':
        req.response.notFound();
        break;

      case 'respondWithJson':
        req.response.json({'key': 'value'});
        break;
    }
  }
}

License #

MIT

Author #

Andrei Lesnitsky

GitHub stars Twitter Follow

0
likes
80
pub points
0%
popularity

Publisher

lesnitsky.dev

Sugar methods for HttpRequest and HttpResponse

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on http_sugar