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

[QUESTION] Working with environment variables #213

Open
rominasilvera opened this issue Apr 30, 2024 · 0 comments
Open

[QUESTION] Working with environment variables #213

rominasilvera opened this issue Apr 30, 2024 · 0 comments
Labels
bug not-confirmed not-confirmed bugreport

Comments

@rominasilvera
Copy link

Hi, I was wondering if you could provide some support on this situation:
I'm new to RestRserve (I have only worked with Plumber), my development os is windows and my pre-production os is linux. I created a simple function that returns the branch, therefore, the code uses environment variables.

Here's the code:

library(RestRserve)

print('-- Create Application --')
app = Application$new(
  # content_type = 'application/json' 
)

app$add_post(
  path = "/whatbranch", 
  FUN = function(.req, .res) {
    print(".req$body:")
    print(.req$body)
    print(paste('-- YOU ARE IN:',Sys.getenv('ENTORNO'),'--'))
    .res$set_content_type("application/json")
    .res$set_body(Sys.getenv('ENTORNO'))
  }
)

backend = BackendRserve$new()
backend$start(app, http_port = 8001)

When I test this function on Postman, the output is as expected:
image

However, when putting this code in production, the ouput is black:
(the response)
image

(the code prints)
image

The r environ file has all the necessary environment variables in all branches.

Also, I noticed that, is it's mandatory for me to "declare" (in production) my main .LibPath at the top of the script ( .libPaths("/home/romina/R/x86_64-pc-linux-gnu-library/4.3")) , otherwise, the libraries can't be installed.

On this page some guidelines for deploying are shown, for example, for setting the port of the app they use:

configuration = c("http.port" = "8001",
                             "encoding" = "utf8",
                              "port" = "6311")

So I was wondering if I could add the environment variables in this vector.

Thanks in advance, I'm really looking forward to use this library.

@rominasilvera rominasilvera added bug not-confirmed not-confirmed bugreport labels Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug not-confirmed not-confirmed bugreport
Projects
None yet
Development

No branches or pull requests

1 participant