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 withServerParams() API to Slim PSR-7 request objects. #105
Conversation
@adriansuter this isn't part of the spec. It's just a helper function. I'm not opposed to adding it, it does seem like more of a usage specific helper though. @soatok why do you need to mutate the server params though? During a request's life, it should technically be instantiated with the correct server params from the get go no? Can you please enlighten us as to why that's necessary? |
I described this in my first comment. This creates a mutated copy of This could be easily implemented at a framework level if I wanted to just make an anomymizer middleware by allowing mutation. My current implementation forces me to just rebuild a new |
@l0gicgate Shouldn't that go to https://github.com/slimphp/Slim-Http? |
@adriansuter the thing is I'm not sure it belongs on either repository, I'm uneasy with modifying server params after request object has been instantiated. I understand that for this particular use case it makes things easier, but what other use cases is that for and are we opening something up that we shouldn't. |
The current usage (as of my PR) is consistent with the other Its absence is noteworthy compared to From an API consistency and end user expectation perspective, this should be included if the other methods are to remain as well. |
@soatok those methods are intended to modify parameters that should be modified as per the PSR-7 interface specs. Modifying server params isn't something that should be done. Those params are passed from the top down, they're not meant to be mutated. |
I think there is a reason why this method didn't make it into the PSR-7 specs. |
I can work around its absence but it's hacky. I still contend that having a more consistent API (a If you want to exclude the capability for the reasons stated in this discussion, it should be a dummy method that throws an exception instead of simply not existing. public function withServerParams() {
throw new NotImplementedException("You're being very silly, developer.");
} |
@soatok I think you're the one being "very silly". Following the PSR-7's spec design, modifying server params isn't part of the interfaces for a reason. In that regard, we will not be implementing this functionality. |
I'd like you to revisit my comment again for a moment.
I don't think that was ever up for debate. Maybe you misunderstood the intent, but I wasn't namecalling. I'll send an alternative patch with a less tongue-in-cheek exception message. |
No need for such patch, don't waste your time. It's not part of the PSR-7 spec so there are no expectations there, we're not going to implement it. Thanks. |
This was missing from the latest release, although I expected it to exist. I mostly need it for unit tests, but I also wrote an IP address anonymizer that might work well with Slim's PSR-7 library.