Kenny,

Take a look at this repo: https://github.com/open-company/open-company-api

We're using Liberator with: [jumblerg/ring.middleware.cors "1.0.1"]

Works fine...

The middleware handles the CORs portion of the response:

https://github.com/open-company/open-company-api/blob/mainline/src/open_company/app.clj#L51

And then we handle the methods portion of the response with standard 
Liberator stuff:

https://github.com/open-company/open-company-api/blob/mainline/src/open_company/api/common.clj#L23
https://github.com/open-company/open-company-api/blob/mainline/src/open_company/api/common.clj#L170
https://github.com/open-company/open-company-api/blob/mainline/src/open_company/api/common.clj#L191
https://github.com/open-company/open-company-api/blob/mainline/src/open_company/api/common.clj#L197
https://github.com/open-company/open-company-api/blob/mainline/src/open_company/api/companies.clj#L123
https://github.com/open-company/open-company-api/blob/mainline/src/open_company/api/companies.clj#L129
https://github.com/open-company/open-company-api/blob/mainline/src/open_company/api/companies.clj#L140

Cheers,
Sean



On Friday, October 14, 2016 at 12:21:34 PM UTC-4, Kenny Liu wrote:
>
> Yep, I tried a non-liberator POST, and it went through perfectly. So right 
> now it seems like liberator is doing something wonky to my 
> requests/responses.
>
> On Friday, October 14, 2016 at 8:22:29 PM UTC+8, Kenny Liu wrote:
>>
>> Anyone know if this all works out of the box? Preflight OPTIONS is 200 
>> but the GET/POST fails. My attempt to get it working:
>>
>> (def app
>>   "Order must be reversed. See: 
>> http://stackoverflow.com/q/19455801/894091";
>>   (-> (bidi/make-handler v1-routes)
>>       (wrap-defaults api-defaults)
>>       (wrap-cors :access-control-allow-origin [#".*"]
>>                  :access-control-allow-headers ["Host"
>>                                                 "User-Agent"
>>                                                 "Accept"
>>                                                 "Accept-Language"
>>                                                 "Accept-Encoding"
>>                                                 "Content-Type"
>>                                                 "Referer"
>>                                                 "Content-Length"
>>                                                 "Origin"
>>                                                 "Connection"
>>                                                 "Pragma"
>>                                                 "Cache-Control"]
>>                  :access-control-allow-methods [:get :put :post :delete
>> ])))
>>
>> http://stackoverflow.com/q/39789487/894091
>>
>> Based on https://github.com/clojure-liberator/liberator/issues/76, I 
>> suspect it might be liberator messing with something. I'm pretty stumped.
>>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to