Home > Enterprise >  Can i write a firebase cloud function once and run it as both onCall and onRequest
Can i write a firebase cloud function once and run it as both onCall and onRequest

Time:06-04

I wish to be able to write e Cloud Function and call it as a callable from a web app, but also with a https request, for example from a python program using admin SDK.

Is there a way to do it? Arguments are different (req,res) vs (data, context).

That's because I have both a web app and a python program, and I see there is no way to call firebase functions from python, or maybe is not documented.

Any suggestions?

CodePudding user response:

Since the protocols for Callable functions an HTTP functions are different, you will need a separate entry point for each. Behind the scenes you an of course re-use most of the code, but they'll need to have separate endpoints.

The only way I can think of combining them is if you implement the Callable protocol yourself in a HTTP function.

  • Related