https://github.com/ijlyttle/httrplus
Addons for https://github.com/hadley/httr that one day may be worthy of a PR
https://github.com/ijlyttle/httrplus
Last synced: 18 days ago
JSON representation
Addons for https://github.com/hadley/httr that one day may be worthy of a PR
- Host: GitHub
- URL: https://github.com/ijlyttle/httrplus
- Owner: ijlyttle
- Created: 2015-08-30T14:16:04.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-08-31T00:38:41.000Z (almost 11 years ago)
- Last Synced: 2026-06-13T13:32:59.302Z (18 days ago)
- Language: R
- Size: 125 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# httrplus
Addon to the `httr` package.
The intention is for this package to be short-lived, and to serve as a converstation-starter to a pull-request to `httr`.
The purpose is to propose a framework around `httr::stop_for_status()` and `httr::warn_for_status()`. The aim is for you to be able to more-easily customise messsages and error/warning-signalling behaviour when using `httr`.
The central function in this package is `check_for_status()`. Its arguements are:
* `resp` - a `httr::response` object
* `type` - one of `c("error", "warning", "message")`
* `message_function` - a function that takes `resp` as its first arguement, returns message
* `...` - additional arguements to `message_function`
The default `message_function` is `message_standard()` (provided here), a function that replicates the messages returned by `httr::stop_for_status()` and `httr::warn_for_status()`
Hence, the existing `httr` functions could be rewritten:
```R
stop_for_status <- function(x){
check_for_status(x, type = "error")
}
warn_for_status <- function(x){
check_for_status(x, type = "warning")
}
```
Another message function is offered: `message_verbose()`.
## Installation
This package is not yet on CRAN (and hopefully won't be).
To get the current development version from github:
```R
# install.packages("devtools")
devtools::install_github("ijlyttle/httrplus")
```