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

batch requests #3

Open
scottcorgan opened this issue May 21, 2014 · 6 comments
Open

batch requests #3

scottcorgan opened this issue May 21, 2014 · 6 comments

Comments

@scottcorgan
Copy link
Member

Define batch requests for a single endpoint through the proxy. The setting in superstatic.json would be the following:

{
  "proxy": {
    "api": {
      "origin": "https://api.github.com",
      "batch": {
        "/repos/repo1/:repo1/repo2/:repo2": {
          "repo1": "/repos/:repo1",
          "repo2": "/repos/:repo2"
        }
      }
    }
  }
}

Ultimately the user can still make normal proxy requests, but normal requests that match the batch route would be be considered a batch request and handled accordingly.

The above example would return the follow for the request /repos?repo=superstatic&repo2=divshot-cli in the response:

{
  repo1: {/* superstatic repo data */},
  repo2: {/* divshot-cli repo data */
}
@collin
Copy link

collin commented May 21, 2014

Rather than force the configuration to pre-suppose all possible batching, I think it makes more sense to supply a more generic batching endpoint:

/__/proxy/batch/api?value1=/repos/divshot/superstatic&value2=/repos/divshot/divshot-cli
{
  value1: {/* superstatic repo data */},
  value2: {/* divshot-cli repo data */}
}

@scottcorgan
Copy link
Member Author

Nice. Any particular reason you put "batch" before "api"?

I was thinking:

/__/proxy/api/?batch=/repos/divshot/superstatic,/repos/divshot/divshot-cli

@collin
Copy link

collin commented May 21, 2014

It's before api to reduce ambiguity. with

/__/proxy/api/?batch=/repos/divshot/superstatic,/repos/divshot/divshot-cli

It is ambiguous whether you want to request a batch of urls, or have a request proxied to github that has a path of / and a query parameter of batch=[...]

@scottcorgan
Copy link
Member Author

Makes sense. Do you think that would cause any issues if the batched urls contain query parameters themselves?

@collin
Copy link

collin commented May 21, 2014

That I'm not sure, seems like it could cause trouble if the urls coming in also have commas in them.

@collin
Copy link

collin commented May 21, 2014

We could require that batch parts that have commas in the url be escaped

escape(",")
=> "%2C"

Then we can just split the batch by ',' and unescape.

Most users wouldn't have to do the escaping as commas and urls are rare, but it would let us support 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

No branches or pull requests

2 participants