r0man / ring-cors

Ring middleware for Cross-Origin Resource Sharing.
http://github.com/r0man/ring-cors
169 stars 44 forks source link

ring-cors returns response with only normalized headers when handler returns nil and origin header is present #5

Open melvinzhang opened 10 years ago

melvinzhang commented 10 years ago

Compojure and other libraries that compose different handlers together expect to try handlers until the first one which returns a response map. Handlers indicate they do not handle a particular request by returning nil instead of a response map.

When wrapping a handler in ring-cors, (add-access-control request (handler request) access-control)) always returns a response map even when (handler request) is nil, this breaks the first non-nil handler logic of routing libraries.

r0man commented 10 years ago

Patch and tests welcome ...

scottyw commented 10 years ago

Hi @r0man, just wondering if that fix I've proposed looks OK to you? Appreciate the help.