Skip to content
This repository was archived by the owner on Dec 15, 2021. It is now read-only.

Added CORS support for golang image for PR #934 #935

Closed
wants to merge 1 commit into from

Conversation

vallard
Copy link

@vallard vallard commented Oct 26, 2018

Issue Ref: #934

Description:
Add CORS to golang runtime.

[PR Description]
Added headers for CORS to the golang runtime.

TODOs:

  • Ready to review
  • Automated Tests
  • Docs

Copy link
Contributor

@andresmgot andresmgot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the PR! I have a suggestion


// add CORS support
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to accept any request and let the user function deal with methods/headers. For doing so, and for consistency with the NodeJS approach, we can just return the same headers received. Also, I think we should just set these headers when the request is a CORS request:

w.Header().Set("Access-Control-Allow-Origin", "*")
if r.Method == "OPTIONS" {
  w.Header().Set("Access-Control-Allow-Methods", r.Header.Get("access-control-request-method"))
  w.Header().Set("Access-Control-Allow-Headers", r.Header.Get("access-control-request-headers"))
  return
}

@andresmgot
Copy link
Contributor

Hi @vallard, we have migrated the code of the runtimes to this new repository: https://github.com/kubeless/runtimes

I have migrated your proposal to this PR: vmware-archive/runtimes#9 please take a look if you have a chance. I am closing the PR in this repo.

@andresmgot andresmgot closed this Nov 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants