captncraig / cors

Cross Origin Resource Sharing middleware for go
MIT License
19 stars 19 forks source link

Couple of syntax recommendations #1

Closed mholt closed 9 years ago

mholt commented 9 years ago

I noticed while going through the docs for cors that allowedHeaders and exposedHeaders are comma-separated lists (and I think methods and origin might be, too). Caddyfile generally separates arguments using spaces, so instead of:

allowedHeaders   X-Custom-Header,X-Foobar

you would have:

allowedHeaders   X-Custom-Header X-Foobar

Would this be a change you'd agree with making, for consistency?

Also, the camelCasing or whatever it's called of some of the keywords like allowCredentials is a little inconsistent; typically we stick with all lowercase words or, if necessary, separate the words with underscore: allow_credentials. (proxy was the first to do this, I think - but it stuck) What would you think about either finding shorter names or switching to the underscore syntax?

captncraig commented 9 years ago

I'm totally ok with both of those. I'll have it ready soon.

captncraig commented 9 years ago

Actually, methods, allowed_headers, and exposed_headers should probably stay. They are really just copied into response headers as-is, so the go code never needs to treat them as lists. They are just strings.

mholt commented 9 years ago

Ah, that makes sense. Sounds good to me. I'll clarify that in the docs.

captncraig commented 9 years ago

origin in the config block actually accepts space or comma seperated, and as an inline-parameter it accepts commas. It can accept any or all of the above:

cors / foo.com,bar.com{
   origin a.com b.com c.com,d.com
}

is technically valid.

mholt commented 9 years ago

Thanks for the changes!