larskuhtz / wai-cors

A Haskell implementation of Cross-Origin resource sharing (CORS) for Wai
MIT License
26 stars 13 forks source link

Add ServantWai.hs example #13

Closed atcol closed 7 years ago

atcol commented 7 years ago

It was hard to find how to use wai-cors with Servant because I wasn't able to find an example, so I wrote one. Most "documentation" for this scenario was actually in the form of comments on an issue for Servant's project. I hope this makes things a little easier for others.

larskuhtz commented 7 years ago

Thanks, for contributing the example!

Your example actually demonstrates the usage with any Wai application, not just servant applications.

On the longer term, it would be nice to integrate CORS with a servant specification (on type level) and than use the wai-cors package as implementation.

atcol commented 7 years ago

I hadn't realised it was more generic - I needed CORS for a project using Servant and had to work quite a few things out, so thought I'd show this. Glad it was more generally applicable. If I write anything that might cover CORS @ the type level then I'll be sure to contribute further.

Thanks again for the API.