Never raises on an HTTP or a parse failure. Returns an envelope for every
outcome, so a caller branches on res$status and writes no tryCatch() of
its own.
Arguments
- req
An httr2 request, prepared with
req_defaults().- source
A friendly label for the service, used in the user-facing message. For example
"gnomAD".- secret_query
A named list of query-string credentials. Appended here rather than by the caller, so
reqitself never carries them and neither does anything built fromreq$url. Seeredact_secrets().
Value
An envelope. See envelope().
Details
Short-circuits to a skipped envelope without sending anything when the
host's breaker is open. See breaker_open().
The request must have been through req_defaults(), which disarms httr2's
error raising. Without that, req_perform() throws on a non-2xx and a
perfectly reachable host is recorded as a transport failure.
Examples
breaker_reset()
req <- req_defaults(httr2::request("https://mock.test/x"))
httr2::with_mocked_responses(
list(httr2::response(
status_code = 200,
headers = list(`content-type` = "application/json"),
body = charToRaw('{"symbol":"BRCA1"}')
)),
perform(req, "MyGene")$data$symbol
)
#> [1] "BRCA1"