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

Provide built-in HTTP response factories, support PSR-17 #2056

Closed
codeguy opened this issue Nov 19, 2016 · 11 comments
Closed

Provide built-in HTTP response factories, support PSR-17 #2056

codeguy opened this issue Nov 19, 2016 · 11 comments

Comments

@codeguy
Copy link
Member

codeguy commented Nov 19, 2016

Implement HTTP factories for PSR-7 response object creation, covering:

  • Success
  • Created
  • Redirect
  • BadRequest
  • Forbidden
  • NotFound
  • Error

Also perhaps factory methods to return new Response for content types (e.g. JSON, XML, CSV).

NOTE: Updated this post based on subsequent discussion.

@codeguy codeguy added the Slim 4 label Nov 19, 2016
@codeguy codeguy added this to the 4.0 milestone Nov 19, 2016
@geekish
Copy link
Contributor

geekish commented Nov 19, 2016

Wouldn't a ResponseFactory be better than making a Response class for every possible status?

@codeguy
Copy link
Member Author

codeguy commented Nov 19, 2016

We'll hit the main ones I think. We could also do something like JsonResponse(), etc. /cc @akrabat

@codeguy
Copy link
Member Author

codeguy commented Nov 19, 2016

@geekish Can you post a very brief snippet of code that demonstrates what you're thinking?

@geekish
Copy link
Contributor

geekish commented Nov 19, 2016

Looks like they're trying to create a PSR for HTTP factories, think something like this:
https://github.com/http-interop/http-factory-slim/blob/master/src/ResponseFactory.php

But with some methods like:

public function createRedirectResponse($url, $status = 302) {
    return (new Response)->withHeader('Location', $url)->withStatus($status);
}
public function createJsonResponse($url, $content) {
    // basically the code Response->withJson() does
}

@geggleto
Copy link
Member

//cc @codeguy @akrabat @geekish Yes this is on my todo list. We should have proper factory classes to make the HTTP Objects.

@codeguy
Copy link
Member Author

codeguy commented Nov 20, 2016

@codeguy
Copy link
Member Author

codeguy commented Nov 20, 2016

@codeguy codeguy changed the title Provide built-in HTTP response objects Provide built-in HTTP response factories Nov 20, 2016
@codeguy codeguy changed the title Provide built-in HTTP response factories Provide built-in HTTP response factories, support PSR-17 Nov 20, 2016
@codeguy
Copy link
Member Author

codeguy commented Dec 1, 2016

See #2048 (comment)

@geggleto geggleto modified the milestone: 4.0 Mar 19, 2017
@tuupola
Copy link
Contributor

tuupola commented Dec 25, 2017

For reference there is currently two PSR-17 implementations supporting Slim. Mine is for slim/slim and the second one is for slim/http.

https://github.com/tuupola/http-factory
https://github.com/http-interop/http-factory-slim

HTTP Interop also provides integration tests.

https://github.com/http-interop/http-factory-tests

@akrabat
Copy link
Member

akrabat commented Sep 16, 2018

This is a Slim-Http thing. See slimphp/Slim-Http#27

@akrabat akrabat added the Has PR label Sep 16, 2018
@l0gicgate
Copy link
Member

Closing, this has been resolved. Slim-Psr7/pull/27 has been merged.

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

6 participants