neomerx / cors-psr7

Framework agnostic (PSR-7) CORS implementation (www.w3.org/TR/cors)
Apache License 2.0
65 stars 14 forks source link

Framework support #3

Closed neomerx closed 9 years ago

neomerx commented 9 years ago

Definitely as a separate project. Possible integration

neomerx commented 9 years ago

@barryvdh Haven't you thought about supporting PSR-7 in your CORS package as Symfony and Laravel support it since recently? This package supports PSR-7 and I quickly respond to questions and PRs.

I would appreciate some feedback from you.

barryvdh commented 9 years ago

Well yeah, but https://github.com/asm89/stack-cors is based on StackPHP so also works on Laravel + Symfony.

And PSR-7 still needs conversions, so you would need the PSR7 message bridge + diactoros. And it didn't work 100% okay with middleware yet, because there is no defined interface for the response object.

So I like the idea of PSR-7 for CORS, but don't see the benefit for Laravel yet.

neomerx commented 9 years ago

@barryvdh The package uses 3 methods from PSR-7 and doesn't depend on responses interface

Also it could be easily integrated with StackPHP. You can see it in the front page sample

barryvdh commented 9 years ago

Ehh, so your package doesn't add actually add the headers in the middleware?

neomerx commented 9 years ago

@barryvdh Nope. It's designed to implement all the CORS logic with as little dependencies as possible. It analyzes the Request (with these 3 simple methods) and returns the analysis result with array of CORS headers to be added.

neomerx commented 9 years ago

@barryvdh I've started developing Service Provider for Laravel. I can send you a link when early version is ready.

neomerx commented 9 years ago

@barryvdh I would prefer it to be a part of a project with good documentation and community rather than re-creating something very similar. Your underlying project hasn't been updated for more than a year. It's abandoned and needs replacement.

barryvdh commented 9 years ago

Yeah but it's not like ths CORS spec changes much ;)

neomerx commented 9 years ago

You just have forgotten your own PR to this project. It's still not merged :wink:

neomerx commented 9 years ago

@barryvdh As promised send you a link to Laravel integration. I have looked to your code and got a question. Why did you decide you need 'route level' support in your middleware? CORS is designed to be transparent and compatible to non CORS services so you could've left it for top level middleware only.

barryvdh commented 9 years ago

Because you could possibly want to allow cors for just your /API routes, not your normal routes.

neomerx commented 9 years ago

@barryvdh Anyways I hope I have dispelled your doubts that this package can do CORS without overhead. So you if you are interested to work with maintainers who maintains their projects and in posibility to migrate to PSR-7 in no time you are welcome :wink: