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

Call a function running locally #97

Closed
joserocha3 opened this issue Feb 1, 2018 · 3 comments
Closed

Call a function running locally #97

joserocha3 opened this issue Feb 1, 2018 · 3 comments

Comments

@joserocha3
Copy link

Is there a way to call a function running locally?

Instead of https://us-central1-project-id.firebaseapp.com/ it would run at say http://localhost:5000/.

function* callFunction() {
  // Will make a POST request to https://us-central1-project-id.firebaseapp.com/sayHello?name=Alfred
  // with custom headers
@n6g7
Copy link
Owner

n6g7 commented Feb 2, 2018

Hi Jose,

That's a good idea, I hadn't thought about this! 🙂

I can see two options to do that:

  • allow the first argument of functions.call to be either a function name (current behaviour) or a full URL. In the latter case we wouldn't automatically generate a xxx.cloudfunctions.net URL and just use what was passed by the user.
    // Calls 'http://localhost:5000/greet?name=Jose':
    yield rsf.functions.call(
      'http://localhost:5000/greet',
      { name: 'Jose' }
    )
  • create a new baseUrl property in rsf that is used to generate the url, ie:
    rsf.baseUrl = 'http://localhost:5000/'
    
    [...]
    
    // Calls 'http://localhost:5000/greet?name=Jose':
    yield rsf.functions.call(
      'greet',
      { name: 'Jose' }
    )
    If not specified, we'd default to a xxx.cloudfunctions.net url.

Thoughts?
I'm inclined to go with the first option because it's more flexible, although it does require the user to provide (and build) the full URL for each call.

@joserocha3
Copy link
Author

joserocha3 commented Feb 6, 2018 via email

@n6g7
Copy link
Owner

n6g7 commented Feb 6, 2018

@joserocha3 Thanks for the encouragement!

This is now available in v0.11, let me know how that works for you. :)

@n6g7 n6g7 closed this as completed Feb 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants