Skip to content

[4.x] Add method to customize the response factory class in the slim http psr17 factory#2713

Closed
adriansuter wants to merge 1 commit into
slimphp:4.xfrom
adriansuter:patch-responseFactoryClass
Closed

[4.x] Add method to customize the response factory class in the slim http psr17 factory#2713
adriansuter wants to merge 1 commit into
slimphp:4.xfrom
adriansuter:patch-responseFactoryClass

Conversation

@adriansuter

Copy link
Copy Markdown
Contributor

This PR addresses #2712.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 100.0% when pulling 95a2ea2 on adriansuter:patch-responseFactoryClass into 0594fb8 on slimphp:4.x.

@adriansuter

Copy link
Copy Markdown
Contributor Author

How would we be able to set a custom http decorator?

@l0gicgate

Copy link
Copy Markdown
Member

You'd need to create your own ResponseFactory then use AppFactory::setResponseFactory($yourCustomFactory)

Then create your own ServerRequestCreator and do ServerRequestCreatorFactory::setServerRequestCreator($yourCustomServerRequestCreator).

@adriansuter

Copy link
Copy Markdown
Contributor Author

Wouldn't it be nice, that if you use one of the built-in PSR-7 implementations, then you just have to set the custom http decorator response factory to the slim http psr17 factory? Then Slim does automatically decorate as before.

@l0gicgate

Copy link
Copy Markdown
Member

How many decorator libraries are there for PSR-7 decoration besides Slim-Http? I don't know of any.

@adriansuter

Copy link
Copy Markdown
Contributor Author

Agree. So you think that this should not be an option? Either you use Slim-Http or you have to create your own response factory and server request creator.

@l0gicgate

Copy link
Copy Markdown
Member

If we were to do it correctly, we'd need to create a decorator provider specifically for that purpose. Opening up the SlimHttp provider with that setter just seems like a hackish way to do it. So for now, unless users end up requesting that feature I don't think it's necessary.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants