spry_urlencoded 0.0.1
spry_urlencoded: ^0.0.1 copied to clipboard
The package provides a middleware and extension for Spry to parse application/x-www-form-urlencoded request body.
Spry Urlencoded #
The spry_urlencoded package provides a middleware and extension for Spry to parse application/x-www-form-urlencoded request body.
Installation #
Add spry_urlencoded to your pubspec.yaml:
dependencies:
spry_urlencoded: latest
Or install it from the command line:
dart pub add spry_urlencoded
Usage #
Read the request.urlencoded property to get the parsed body:
import 'package:spry_urlencoded/spry_urlencoded.dart';
void handler(Context context) async {
print(await context.request.urlencoded());
}
Configuration #
The Urlencoded middleware can be configured with the following options:
encoding- The encoding of the request body. Defaults toutf8.
import 'package:spry/spry.dart';
import 'package:spry_urlencoded/spry_urlencoded.dart';
void handler(Context context) async {
final Map<String, String> urlencoded = await context.request.urlencoded();
print(urlencoded);
}
final spry = Spry();
final urlencoded = Urlencoded(
string: utf8,
part: utf8,
);
spry.use(urlencoded);
await spry.listen(handler, port: 3000);
Note: The
Urlencodedmiddleware is optional. You can use therequest.urlencodedextension method to parse the request body.