Skip to content

Simpler custom requests#254

Merged
pcantrell merged 21 commits intomasterfrom
simpler-custom-requests
Jun 18, 2018
Merged

Simpler custom requests#254
pcantrell merged 21 commits intomasterfrom
simpler-custom-requests

Conversation

@pcantrell
Copy link
Copy Markdown
Member

@pcantrell pcantrell commented Jun 18, 2018

This fixes #152, adding a simpler, better way for apps to create custom Siesta Requests that are completely detached from the underlying network provider. Such requests can for example:

  • wrap a third-party library’s network request (e.g. OAuth),
  • wrap a local load operation (e.g. deserialization) as a request, or
  • implement a time delay

…and when these become Requests, they can all participate in a request chain. This allows, for example, a chain like “on failure, renew the OAuth token, delay 3 seconds, then retry.”

To use the new API, apps implement RequestDelegate and pass it to Resource.prepareRequest(using:). See details in the API docs in the PR.


This PR also adds Resource.hardWiredRequest(returning:), for situations when you already have a fixed response, but want to wrap it as a request. This is a generalization of the existing Resource.failedRequest(…).

@pcantrell pcantrell merged commit d3fd8e4 into master Jun 18, 2018
@pcantrell pcantrell deleted the simpler-custom-requests branch June 18, 2018 16:28
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.

Allow arbitrary non-Siesta promises in request chains

1 participant