Coder Social home page Coder Social logo

plack-middleware-parsecontent's Introduction

NAME

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

SYNOPSIS

    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'}) ] ];
            };
    };

DESCRIPTION

Parse input content and save it to plack env as 'parsecontent.data'.

For complete RestAPI in Perl use:

  • Plack::App::REST
  • Plack::Middleware::FormatOutput

CONSTANTS

DEFAULT MIME TYPES

  • 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.
    

STORED PARAMS TO ENV (Fulfill the PSGI specification)

  • parsecontent.data

    Store parsed data from input content.

TUTORIAL

http://psgirestapi.dovrtel.cz/

AUTHOR

Václav Dovrtěl [email protected]

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

COPYRIGHT

Copyright 2015- Václav Dovrtěl

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

plack-middleware-parsecontent's People

Contributors

biina avatar vasekd avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

plack-middleware-parsecontent's Issues

Setting a parser for application/x-www-form-urlencoded does not work

It can be useful to be able to override the default behaviour for requests with Content-Type: application/x-www-form-urlencoded because some broken clients like to send e.g. JSON bodies without setting the proper Content-Type.

This does not work:

enable 'ParseContent', 'application/x-www-form-urlencoded' => sub { decode_json($_[0]) };

...because the handling for application/x-www-form-urlencoded kicks in before the custom handlers are checked.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.