New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add to Media Parsers #1683

Closed
geggleto opened this Issue Dec 16, 2015 · 2 comments

Comments

Projects
None yet
2 participants
@geggleto
Copy link
Contributor

geggleto commented Dec 16, 2015

@codeguy

This comment has been minimized.

Copy link
Member

codeguy commented Dec 17, 2015

We'll address this soon. I want to discuss future road map with @silentworks and @akrabat first.

@geggleto

This comment has been minimized.

Copy link
Contributor Author

geggleto commented Feb 17, 2016

@codeguy I found a work around for this issue this morning.

By overriding the default container factory for request, it is possible to register a media parser before the App class is created.

Example:

//...
// Required to manually create the container
$container = new \Slim\Container();
// Create new factory 
$container['request'] = function ($c) {
    // construct request from environment
    $request = \Slim\Http\Request::createFromEnvironment($c['env']);
    // add media parser
    $request->registerMediaTypeParser("text/javascript", function ($input) {
        return json_decode($input, true);
    });
};

// Construct App
$app = new Slim\App($container);
//...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment