The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Plack::Middleware::ParseContent - Parse content of input data by Content-Type header.

VERSION

Version 0.01

SYNOPSIS

        use Plack::Middleware::ParseContent;

        builder {
                enable 'ParseContent', xyz => sub{ return {test => $_[0]} };
                mount "/" => sub { 
                        my ($env) = @_;

                        ### Make some action with posted data
                        $env->{'restapi.parseddata'};

                        return [ 200, [ 'Content-Type' => 'text/plain' ], [ 'app/root' ] ];
                };
        };

DESCRIPTION

Parse input content and save it to plack env as 'restapi.parseddata'.

For complete RestAPI in Perl use:

  • Plack::Middleware::RestAPI

  • Plack::Middleware::SetAccept

  • Plack::Middleware::FormatOutput

CONSTANTS

DEFAULT MIME TYPES

  • application/json

  • text/yaml

  • text/plain

STORED PARAMS TO ENV (Fulfill the PSGI specification)

restapi.parseddata

Store parsed data from input content.

TUTORIAL

http://psgirestapi.dovrtel.cz/

AUTHOR

Vaclav Dovrtel, <vaclav.dovrtel at gmail.com>

BUGS

Please report any bugs or feature requests to github repository.

ACKNOWLEDGEMENTS

Inspired by https://github.com/towhans/hochschober

REPOSITORY

https://github.com/vasekd/Plack-Middleware-ParseContent

LICENSE AND COPYRIGHT

Copyright 2015 Vaclav Dovrtel.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.