Skip to content

Instantly share code, notes, and snippets.

@iokasimov
Created August 18, 2016 11:04
Show Gist options
  • Save iokasimov/216cdfb1496f4013dad34dce1500965c to your computer and use it in GitHub Desktop.
Save iokasimov/216cdfb1496f4013dad34dce1500965c to your computer and use it in GitHub Desktop.

Explanation of working asynchronous API:

List of endpoints:

  • GET /detect
  • POST /detect
  • GET /detect/state
  • GET /detect/result

So, we have 4 methods: the first two are doing the same things - just starts detecting, the third is checking on state of detecting, the fourth outputs the result.

For example:

  1. Client send a document to detect forms -> GET /detect, it starts async queue (or POST, never mind).
  2. Client want monitor state of detecting on forms in document - ready yet? -> GET /detect/state.
  3. If not, server responds: "Oh, dude, this is not ready yet, I'm busy".
  4. If document is ready, server responds: "Yeah, done!" and returns redirect on /detect/result.
  5. And now, client got forms, that have been pulled out from document.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment