Coder Social home page Coder Social logo

Comments (13)

hannesvdvreken avatar hannesvdvreken commented on July 3, 2024 1

That's it? Then I'd lean more towards my first proposal: deprecate JsonStrategy, and make a new JsonResponseStrategy, tag 2.1.0 and be done with it.

from route.

hannesvdvreken avatar hannesvdvreken commented on July 3, 2024

Is it perhaps possible to make a different strategy and deprecate the old one? Then you'd be fine with a new minor.

I'm OK with a v3 as well, though.

from route.

hannesvdvreken avatar hannesvdvreken commented on July 3, 2024

If it's a small change, could you provide a branch to showcase the changes and discuss further based on that?

from route.

philipobenito avatar philipobenito commented on July 3, 2024

The discussion is going to dictate where I go with the code.

The breaking change would be here https://github.com/thephpleague/route/blob/master/src/Strategy/JsonStrategy.php#L19 where I would be adding the response object as the second parameter on this call.

from route.

philipobenito avatar philipobenito commented on July 3, 2024

And just have the original strategy ignore the new middleware functionality?

from route.

hannesvdvreken avatar hannesvdvreken commented on July 3, 2024

Maybe, does that seem plausible to you?

from route.

philipobenito avatar philipobenito commented on July 3, 2024

Yeah, I think that works for me.

RequestResponseStrategy & JsonResponseStrategy - can add middleware and will invoke them.

JsonStrategy & ParamStrategy - throw exception when dispatching on this strategy and a middleware is found?

JsonStrategy - deprecated and will be removed in version 3.0.0?

from route.

philipobenito avatar philipobenito commented on July 3, 2024

Maybe actually have it as JsonRequestResponseStrategy, that way all strategies going forward that are suffixed RequestResponseStrategy can be used with middleware and we don't necessarily need to deprecate the JsonStrategy?

That way we can continue to introduce strategies and it has a format. As in SomeStrangeFormatRequestResponseStrategy etc down the line.

from route.

hannesvdvreken avatar hannesvdvreken commented on July 3, 2024

Deprecating JsonStrategy isn't necessary, no. But you'd want that to avoid confusion why there are 2 json related strategy classes, and if you want to remove it in v3.

from route.

philipobenito avatar philipobenito commented on July 3, 2024

Well there would be value in keeping both, the difference would just have to be explained thoroughly.

JsonRequestResponseStrategy you would be expected to manipulate the response and return it.

JsonStrategy would attempt to build a response from what you return (array, json string etc).

from route.

CMCDragonkai avatar CMCDragonkai commented on July 3, 2024

Route 2.x is not compatible with things like League\Relay right?

from route.

hannesvdvreken avatar hannesvdvreken commented on July 3, 2024

@CMCDragonkai I guess you meant https://github.com/relayphp/Relay.Relay ? League\Relay doesn't exist, afaik.

if you have a League\Route\RouteCollection object, you can use [$routeCollection, 'dispatch'] (which is a PHP callable) to pass to Relay as a middleware.

from route.

CMCDragonkai avatar CMCDragonkai commented on July 3, 2024

Yes that's what I meant. Oh that's nice. Hopefully this can be clearer in the docs.

from route.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.