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

Simpler custom requests #254

Merged
merged 21 commits into from
Jun 18, 2018
Merged

Simpler custom requests #254

merged 21 commits into from
Jun 18, 2018

Conversation

pcantrell
Copy link
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