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

Variety of response classes (Json, Csv, etc.) #7

Open
peterhorne opened this issue May 5, 2012 · 2 comments
Open

Variety of response classes (Json, Csv, etc.) #7

peterhorne opened this issue May 5, 2012 · 2 comments
Milestone

Comments

@peterhorne
Copy link
Owner

If the user sets body to an array instead of a string (via __constructor, or $response['body']) then the array should be converted to a json string and the appropriate headers should be set.

@peterhorne
Copy link
Owner Author

Now that Elmer\Response handles __constructor arguments by type rather than position this is not possible to implement. Perhaps custom response objects that extend Elmer\Response would work though?

<?php
$app->get('/json', function() {
    return new JsonResponse($users);
});

$app->get('/csv', function() {
    return new CsvResponse($users);
});

@peterhorne
Copy link
Owner Author

Naming of classes should be under the Elmer\Responses namespace:

<?php
use Elmer\Responses\Json;
use Elmer\Responses\Csv
;
$app->get('/json', function() {
    return new Json($users);
});

$app->get('/csv', function() {
    return new Csv($users);
});

I suggest moving the current response class Elmer\Response into the responses namespace as well. Elmer\Responses\Response or Elmer\Responses\Http

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant