go-chi/cors

License

explodingcamera opened this issue · 12 comments

Hi, I love chi and would like to keep using this middleware, however I can't because it doesn't have a license.
Would you mind maybe adding something like a MIT license to this repo?

@explodingcamera sure, create a PR with a LICENSE file matching go-chi/go and I'm sure we can merge. Thanks

rs commented

Speaking of license, this project is a fork of github.com/rs/cors and removed the original license. You might have missed the part of the original license that says:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

I also don't really understand why you forked the project instead of submitting a PR, but well…

@explodingcamera @rs thanks for pointing this out.

Resolved in #4 and e87e85b.

rs commented

May I ask why this fork is needed?

@rs I'm not sure to be honest. Probably some middleware specific code?

I'll diff the source codes and let you know.

rs commented

I looked at the diff and the only noticeable difference is the passing of the request in the AllowOriginFunc parameter, which 1/ should not make the original library more or less compatible with chi middleware construct, and 2/ is a feature that could have been discussed for addition in the main library.

rs commented

Just added a chi integration example: rs/cors@0202607. It works out of the box.

Yeah, looks like

- AllowOriginFunc func(origin string) bool
+ AllowOriginFunc func(r *http.Request, origin string) bool

is the only major API change. Alongside with some clean-up of Negroni and Martini interfaces, which we've never intended to use.

Let me have a look at the API change a bit deeper.

@rs looks like we do use *http.Request in the AllowOriginFunc to get some additional info about the request itself, ie. what scheme://domain/path the request was meant for and/or potentially some more per-request specific data.

I guess this was the reason for the hard fork originally, since it was a breaking API change.

AllowOriginFunc func(r *http.Request, origin string) bool

Is that something github.com/rs/cors could potentially adopt? Any ideas how, since the function signature is different?

Thanks for taking your time with us.

rs commented

We can introduce a new option with the added param. I think it is useful addition.

@rs AllowOriginRequestFunc ?

rs commented

Yes, something like that