Plack::Middleware::ParseContent - Parse content of input data by Content-Type header.
use Plack::Middleware::ParseContent;
builder {
enable 'ParseContent', 'application/xyz' => sub{ return decode_xyz($_[1]) };
mount "/" => sub {
my ($env) = @_;
return [ 200, [ 'Content-Type' => 'text/plain' ], [ serialize($env->{'parsecontent.data'}) ] ];
};
};
Parse input content and save it to plack env as 'parsecontent.data'.
For complete RestAPI in Perl use:
- Plack::App::REST
- Plack::Middleware::FormatOutput
-
application/json
-
text/yaml
-
text/plain
-
application/x-www-form-urlencoded
As default two keys are expected: enctype and DATA. "enctype" is definition of type that is serialized in DATA.
-
parsecontent.data
Store parsed data from input content.
http://psgirestapi.dovrtel.cz/
Václav Dovrtěl vaclav.dovrtel@gmail.com
Please report any bugs or feature requests to github repository.
Inspired by https://github.com/towhans/hochschober
https://github.com/vasekd/Plack-Middleware-ParseContent
Copyright 2015- Václav Dovrtěl
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.