dia_body 0.1.3 copy "dia_body: ^0.1.3" to clipboard
dia_body: ^0.1.3 copied to clipboard

Request body parser middleware for Dia http serer. Parse query, x-www-form-urlencoded, json and form-data params and uploaded files form HttpRequest.

example/dia_body_example.dart

import 'dart:io';

import 'package:dia/dia.dart';
import 'package:dia_body/dia_body.dart';

class ContextWithBody extends Context with ParsedBody {
  ContextWithBody(HttpRequest request) : super(request);
}

void main() {
  final app = App((req) => ContextWithBody(req));

  app.use(body());

  app.use((ctx, next) async {
    ctx.body = ''' 
    query=${ctx.query}
    parsed=${ctx.parsed}
    files=${ctx.files}
    ''';
  });

  /// Start server listen on localhost:8080
  app
      .listen('localhost', 8080)
      .then((info) => print('Server started on http://localhost:8080'));
}
1
likes
150
pub points
49%
popularity

Publisher

verified publisherawcoding.com

Request body parser middleware for Dia http serer. Parse query, x-www-form-urlencoded, json and form-data params and uploaded files form HttpRequest.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

dia, http_parser, mime, uuid

More

Packages that depend on dia_body