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

HTTP Rest Server #48

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

HTTP Rest Server #48

wants to merge 5 commits into from

Conversation

shikokuchuo
Copy link
Owner

@shikokuchuo shikokuchuo commented Sep 2, 2024

Experimental

Permits evaluation of arbitrary R expressions submitted to an API endpoint.

Client-neutral, supporting any HTTP client.

Run server in a new session:

Rscript -e 'nanonext::server("http://127.0.0.1:5555/api/rest")'

Query using command line curl:

curl -X POST http://127.0.0.1:5555/api/rest -d 'format(Sys.time())'

Query from within R:

ncurl("http://127.0.0.1:5555/api/rest", method = "POST", data = "format(Sys.time())")

res <- ncurl(
  "http://127.0.0.1:5555/api/rest",
  convert = FALSE,
  method = "POST",
  data = "data.frame(random = nanonext::random(3))"
)
unserialize(res$data)

Result is returned as a string where possible supporting non-R clients e.g. command line curl.
Otherwise as a binary R-serialized object, which may be consumed by an R client.

TO-DO:

  • 1. Parse-error handling
  • 2. Consider other return formats

@codecov-commenter
Copy link

codecov-commenter commented Sep 2, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 0% with 141 lines in your changes missing coverage. Please review.

Project coverage is 85.84%. Comparing base (f690074) to head (0b3129c).

Files with missing lines Patch % Lines
src/server.c 0.00% 139 Missing ⚠️
R/server.R 0.00% 2 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #48      +/-   ##
==========================================
- Coverage   89.16%   85.84%   -3.32%     
==========================================
  Files          25       27       +2     
  Lines        3561     3702     +141     
==========================================
+ Hits         3175     3178       +3     
- Misses        386      524     +138     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants