Created
January 18, 2025 19:53
-
-
Save JosiahParry/539f343bc8b17ed1396fcee5ae5cc346 to your computer and use it in GitHub Desktop.
API done 2 wayys ambiorix vs plumber
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app <- ambiorix::Ambiorix$new() | |
app$post("/process", function(req, res) { | |
body <- yyjsonr::read_json_raw(req$rook.input$read()) | |
msg <- sprintf( | |
"Hello, %s! Your age is %i, and your email is %s.", | |
body[["name"]], body[["age"]], body[["email"]] | |
) | |
res$json(list(message = msg, status = "success")) | |
}) | |
app$start() | |
library(plumber) | |
pr() |> | |
pr_post("/process", function(req, res) { | |
msg <- sprintf( | |
"Hello, %s! Your age is %i, and your email is %s.", | |
req$body[["name"]], req$body[["age"]], req$body[["email"]] | |
) | |
list(message = msg, status = "success") | |
}) |> | |
pr_run() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment