Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] Respond appropriately to HTTP OPTIONS method #1957

Closed
wants to merge 3 commits into from
Closed

[wip] Respond appropriately to HTTP OPTIONS method #1957

wants to merge 3 commits into from

Conversation

langston-barrett
Copy link
Contributor

@langston-barrett langston-barrett commented Apr 18, 2016

Enables development of JavaScript API clients that use CORS requests. Also, responding to OPTIONS requests with 200 OK is just a good baseline behavior.

This needs unit tests, but I wanted to get feedback on the way it's implemented first. I'm also happy to rebase & squash when the time comes.

Fixes #865
Obsoletes #1807

If this change is too large, we could also simply respond with 200 to any OPTIONS requests:

        var obj interface{}
        if req.Method == "OPTIONS" {
            obj, err = nil, nil
        } else { // Invoke the handler
            obj, err = handler(resp, req)
        }

For more information on the OPTIONS method, view the HTTP 1.1 RFC 2616, § 9.2. "OPTIONS".

@slackpad
Copy link
Contributor

Hi @siddharthist thanks for the PR and sorry for the delay in looking at this. I'm thinking we should incorporate the listing of allowed methods into here. We could make a new registration function that turns this:

s.mux.HandleFunc("/v1/kv", s.wrap(s.AgentSelf))

Into something like this:

registerEndpoint("/v1/agent/self", "GET,PUT,DELETE", s.wrap(s.KVSEndpoint))

This way we can build the data structure one time alongside the registration of the endpoints. What do you think?

@langston-barrett
Copy link
Contributor Author

@slackpad That makes a lot of sense. Most of the work on this PR was just finding out what endpoints respond to which methods, so I'm happy to redo the code :)

@langston-barrett
Copy link
Contributor Author

@slackpad What are the supported methods on the /v1/txn endpoint?

@langston-barrett langston-barrett changed the title Respond appropriately to HTTP OPTIONS method [wip] Respond appropriately to HTTP OPTIONS method May 19, 2016
@langston-barrett
Copy link
Contributor Author

Closing until I have more time to work on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants