dia_body 0.0.2 dia_body: ^0.0.2 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.
import 'dart:io';
import 'package:dia/dia.dart' as dia;
import 'package:dia_body/dia_body.dart';
class ContextWithBody extends dia.Context with ParsedBody {
ContextWithBody(HttpRequest request) : super(request);
}
void main() {
final app = dia.App<ContextWithBody>();
app.use(body());
app.use((ctx, next) async {
ctx.body = '''
query=${ctx.query}
parsed=${ctx.parsed}
files=${ctx.files}
''';
});
/// Start server listen on localhsot:8080
app
.listen('localhost', 8080)
.then((info) => print('Server started on http://localhost:8080'));
}