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

Restructure body parsers to use content type. Add many parsers #584

Merged
merged 79 commits into from
Jul 31, 2020
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
2c05be1
add check before guessing content-type
Jul 3, 2020
5c78836
PR suggestion, gitattributes
Jul 3, 2020
680bd8e
remove to readd
Jul 3, 2020
161164e
readd binary
Jul 3, 2020
2954c74
Add back ... args to safeFromJSON()
schloerke Jul 3, 2020
4233155
Adjust parsers to allow for arguments. Use direct matches only
schloerke Jul 3, 2020
f392e60
Merge branch 'respect_ctype' of https://github.com/meztez/plumber int…
schloerke Jul 3, 2020
dee07fa
use stringi methods
schloerke Jul 3, 2020
0f27683
Add comments as to why the content type is being altered
schloerke Jul 3, 2020
30ca5ad
Merged name change
schloerke Jul 3, 2020
ddaa3c5
Add a default file name in case one isn't provided
schloerke Jul 3, 2020
11d459c
Add tsv and csv tests. Rename test file.
schloerke Jul 3, 2020
48e7809
add news item
schloerke Jul 3, 2020
79c2972
fix topic names for pkgdown
schloerke Jul 3, 2020
10199b5
Add octet-stream
schloerke Jul 3, 2020
61fec39
Remove invalid content type
schloerke Jul 3, 2020
0d3b795
Do not eval any yaml
schloerke Jul 7, 2020
8110b91
parser plumber tag, parser builder functions return a named list of m…
Jul 9, 2020
b2c0582
passing current tests
Jul 9, 2020
70d3691
change default parsers on router
Jul 9, 2020
bd0a46f
adding @parser none and @parser all, update parsers doc.
Jul 9, 2020
7aa66f6
Apply suggestions from code review
Jul 9, 2020
0479637
update doc, avoid recursively calling parser_all
Jul 9, 2020
290fbf9
re-added parser to content-type test
Jul 9, 2020
4c578a1
Adding test for the parser tag
Jul 9, 2020
0d30e34
remerge fix conflict
Jul 9, 2020
b5efad4
parse_json instead of fromJSON
Jul 9, 2020
8955d8f
Rework parser matching to also do regex on top of (after) fixed match…
Jul 10, 2020
bc0264c
modify make_parsers to handle shortname, fixed and regex for Content-…
Jul 20, 2020
730c4ba
slight change to parser_text reference, use shortname instead of [[1]]
Jul 20, 2020
6ae2da5
Update R/parse-body.R
Jul 20, 2020
beb12a2
Update R/parse-body.R
Jul 20, 2020
de672af
Update R/parse-body.R
Jul 20, 2020
edc2f12
Update R/parse-body.R
Jul 20, 2020
83effa4
Update R/parse-body.R
Jul 20, 2020
cbe8ff9
Move make_parsers to add_parser and associated impact fix
Jul 20, 2020
53efca8
Merge pull request #587 from meztez/post_body_content_type
schloerke Jul 21, 2020
1357e25
Make arg required
schloerke Jul 21, 2020
1b4b0e5
document
schloerke Jul 21, 2020
4023650
display value when selecting
schloerke Jul 21, 2020
05d680d
parser_none should ask for no alias values
schloerke Jul 21, 2020
e00fd23
have all endpoint parsers run through `select_parsers()`. Fixes #612
schloerke Jul 21, 2020
9236241
Nitpick
cpsievert Jul 21, 2020
d178b97
Apply suggestions from code review
schloerke Jul 22, 2020
def1bab
merge master
schloerke Jul 22, 2020
1ae78d4
Rename pr private$parsers to private$default_parsers
schloerke Jul 23, 2020
12fb373
Rename add_parser to register_parser. Allow for TRUE, character vect,…
schloerke Jul 23, 2020
2b950d2
`get_parsers()` -> `make_parser()`; `add_parser()` -> `register_parse…
schloerke Jul 24, 2020
7f09915
plumb block should set up a named list of parser to arguments structu…
schloerke Jul 24, 2020
779b181
Update and add more tests for parsers
schloerke Jul 24, 2020
194fd74
Fix checks and document
schloerke Jul 24, 2020
98fd28a
do not document hookable for now
schloerke Jul 24, 2020
4a4d97b
Heavily update the pkgdown order
schloerke Jul 24, 2020
72acadd
Merge branch 'master' into post_body_content_type
schloerke Jul 24, 2020
364a8e1
change name to sample_name
schloerke Jul 24, 2020
e86ea2e
If have default parsers already be sent through `make_parser()`
schloerke Jul 24, 2020
10c3d38
Remove `parser_all` from exising and being exported as it is not a _r…
schloerke Jul 24, 2020
d503a25
Require readr within the inner parsing function, not in the outer par…
schloerke Jul 24, 2020
4efe31b
document and add more tests and fix tests
schloerke Jul 24, 2020
f8624ed
"remove" addSerializer(). Define register_serializer() and registered…
schloerke Jul 24, 2020
fb3bb70
Fix test
schloerke Jul 24, 2020
c5376d7
Moar docs
schloerke Jul 24, 2020
2ab37b8
Use `local()` rather than `withr::with_options()`
schloerke Jul 24, 2020
733760d
update comments
schloerke Jul 28, 2020
c141fa5
Merge branch 'master' into post_body_content_type
schloerke Jul 28, 2020
18655f7
Eval in proper env (related to #620)
cpsievert Jul 29, 2020
d95325d
Forgot to change the docs
schloerke Jul 31, 2020
71b6aa8
Move parser_read_file down in file
schloerke Jul 31, 2020
1710168
Allow for readr to take original raw value directly
schloerke Jul 31, 2020
d4b6339
rename test file to have it be executed last. (it's slow)
schloerke Jul 31, 2020
8481248
merge master
schloerke Jul 31, 2020
c6c3a09
scope readr parser args properly
schloerke Jul 31, 2020
538e75a
safe guard against temp files possibly being deleted by user
schloerke Jul 31, 2020
0761880
add comment about how readRDS does not work with rawConnection
schloerke Jul 31, 2020
16e01a9
Forgot to add `function` in the pseudo docs
schloerke Jul 31, 2020
7989213
Merge branch 'post_body_content_type' of https://github.com/rstudio/p…
schloerke Jul 31, 2020
6959dd7
Do not export `make_parsers()`. Copy over appropriate docs
schloerke Jul 31, 2020
4d8591f
Do not display docs for `make_parser()`
schloerke Jul 31, 2020
7be4fec
update news entry
schloerke Jul 31, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

schloerke marked this conversation as resolved.
Show resolved Hide resolved
export(PlumberEndpoint)
export(PlumberStatic)
export(addParser)
export(addSerializer)
export(add_parser)
export(do_configure_https)
export(do_deploy_api)
export(do_forward)
Expand All @@ -17,12 +17,15 @@ export(include_html)
export(include_md)
export(include_rmd)
export(options_plumber)
export(parser_csv)
export(parser_json)
export(parser_multi)
export(parser_octet)
export(parser_query)
export(parser_rds)
export(parser_read_file)
export(parser_text)
export(parser_tsv)
export(parser_yaml)
export(plumb)
export(plumber)
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ plumber 1.0.0

* Added yaml support, serializer and parser. (@meztez, #556)

* Added csv and tsv parsers (#584)

* Added csv serializer (@pachamaltese, #520)

* Added svg serializer (@pachamaltese, #398)
Expand Down
4 changes: 3 additions & 1 deletion R/content-types.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ knownContentTypes <- list(
dotx='application/vnd.openxmlformats-officedocument.wordprocessingml.template',
xlam='application/vnd.ms-excel.addin.macroEnabled.12',
xlsb='application/vnd.ms-excel.sheet.binary.macroEnabled.12',
rds='application/rds')
rds='application/rds',
tsv="text/tab-separated-values",
csv="text/csv")

getContentType <- function(ext, defaultType='application/octet-stream') {
ct <- knownContentTypes[[tolower(ext)]]
Expand Down
2 changes: 1 addition & 1 deletion R/globals.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.globals <- new.env()
.globals$serializers <- list()
.globals$processors <- new.env()
.globals$parsers <- list(func = list(), pattern = list())
.globals$parsers <- list()
4 changes: 2 additions & 2 deletions R/json.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#' @importFrom jsonlite validate fromJSON toJSON
#' @noRd
safeFromJSON <- function(txt) {
safeFromJSON <- function(txt, ...) {
if (!validate(txt)) {
stop("Argument 'txt' is not a valid JSON string.")
}
fromJSON(txt)
fromJSON(txt, ...)
schloerke marked this conversation as resolved.
Show resolved Hide resolved
}
Loading