Skip to content
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
Closed

Add to Media Parsers #1683

geggleto opened this issue Dec 16, 2015 · 2 comments

Comments

@geggleto
Copy link
Member

@geggleto geggleto commented Dec 16, 2015

Weird issue in IE.
http://www.entwicklungsgedanken.de/2008/06/06/problems-with-internet-explorer-and-applicationjson/
Add text/javascript for JSON

@codeguy
Copy link
Member

@codeguy codeguy commented Dec 17, 2015

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

@geggleto
Copy link
Member Author

@geggleto 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
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants